本文整理汇总了C#中SQLite.SQLiteConnection.RunInTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# SQLite.SQLiteConnection.RunInTransaction方法的具体用法?C# SQLite.SQLiteConnection.RunInTransaction怎么用?C# SQLite.SQLiteConnection.RunInTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLite.SQLiteConnection.RunInTransaction方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: update
public void update(string name,string address)
{
using (var db = new SQLite.SQLiteConnection(app.dbPath))
{
try
{//db.Execute("update meterbox set currentUnits = currentUnits -" + used);
var existing = db.Query<Job>("select * from Job").First();
if (existing != null)
{
existing.name = name;
existing.address = address;
db.RunInTransaction(() =>
{
db.Update(existing);
});
}
}
catch (Exception e)
{
}
}
}
示例2: DeleteAddress_DeleteAddressEvent
private void DeleteAddress_DeleteAddressEvent()
{
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
using (var db = new SQLite.SQLiteConnection(dbPath))
{
db.RunInTransaction(() =>
{
foreach (User user in AdressBookItems.SelectedItems)
{
db.Delete(user);
}
});
BindLists();
}
}
示例3: DeleteRequest_DeleteRequestEvent
void DeleteRequest_DeleteRequestEvent()
{
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
using (var db = new SQLite.SQLiteConnection(dbPath))
{
db.RunInTransaction(() =>
{
foreach (Appointment appointment in RequestItems.SelectedItems)
{
db.Delete(appointment);
}
});
BindLists();
}
}
示例4: btnRegister_Click
private void btnRegister_Click(object sender, RoutedEventArgs e)
{
if (FieldValidationExtensions.GetIsValid(RegisterUserName) && FieldValidationExtensions.GetIsValid(RegisterPassword) && FieldValidationExtensions.GetIsValid(RegisterEmail))
{
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
using (var db = new SQLite.SQLiteConnection(dbPath))
{
db.CreateTable<User>();
db.RunInTransaction(() =>
{
db.Insert(new User() { UserName = RegisterUserName.Text, PassWord = RegisterPassword.Password, EmailAddress = RegisterEmail.Text });
});
}
this.Frame.Navigate(typeof(MainPage));
}
}
示例5: addMeterBox
public void addMeterBox(string meterBoxNumber, double current)
{
string result = string.Empty;
using (var db = new SQLite.SQLiteConnection(app.DBPath))
try
{
db.CreateTable<MeterBox>();
int success1 = db.Insert(new MeterBox()
{
ID = 0,
meterBoxNumber = meterBoxNumber,
currentUnits = current
});
var existing = db.Query<MeterBox>("select * from MeterBox").First();
if (existing == null)
{
int success = db.Insert(new MeterBox()
{
ID = 0,
meterBoxNumber = meterBoxNumber,
currentUnits = current
});
}
else if(existing != null)
{
existing.meterBoxNumber = meterBoxNumber;
existing.currentUnits = current;
db.RunInTransaction(() =>
{
db.Update(existing);
});
}
}
catch (Exception e)
{
}
//return "Success";
}
示例6: btnAdd_Click
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
if (FieldValidationExtensions.GetIsValid(AddressbookUserName) && FieldValidationExtensions.GetIsValid(AddressbookEmail))
{
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
using (var db = new SQLite.SQLiteConnection(dbPath))
{
db.CreateTable<AddressBookEntree>();
User addressbookuser = new User();
addressbookuser.UserName = AddressbookUserName.Text;
addressbookuser.EmailAddress = AddressbookEmail.Text;
db.RunInTransaction(() =>
{
db.Insert(addressbookuser);
db.Insert(new AddressBookEntree() { OwnerUserID = App.loggedInUser.Id, EntreeUserID = addressbookuser.Id });
});
}
}
this.Frame.Navigate(typeof(Dashboard));
}
示例7: updateMeterBoxUnits
public void updateMeterBoxUnits(double used)
{
double rem = 0.0;
using (var db = new SQLite.SQLiteConnection(app.DBPath))
{
try
{//db.Execute("update meterbox set currentUnits = currentUnits -" + used);
var existing = db.Query<MeterBox>("select * from MeterBox").First();
if (existing != null)
{
existing.currentUnits = existing.currentUnits - used;
db.RunInTransaction(() =>
{
db.Update(existing);
});
}
}
catch (Exception e)
{
}
}
}
示例8: btnAdd_Click
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
if (FieldValidationExtensions.GetIsValid(RequestTitle) && FieldValidationExtensions.GetIsValid(RequestLocation) && FieldValidationExtensions.GetIsValid(RequestDescription))
{
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
using (var db = new SQLite.SQLiteConnection(dbPath))
{
db.CreateTable<Appointment>();
db.CreateTable<AppointmentInvitee>();
Appointment appointment = new Appointment();
appointment.Title = RequestTitle.Text;
appointment.Location = RequestLocation.Text;
appointment.Description = RequestDescription.Text;
appointment.Date = RequestDate.SelectedDate;
appointment.OwnerUserID = App.loggedInUser.Id;
db.RunInTransaction(() =>
{
db.Insert(appointment);
foreach (UserSelected item in mUsersSelected)
{
if (item.IsSelected)
{
db.Insert(new AppointmentInvitee() { OwnerUserID = App.loggedInUser.Id, InviteeAppointmentID = appointment.Id, InviteeUserID = item.Id });
}
}
});
}
this.Frame.Navigate(typeof(Dashboard));
}
}