当前位置: 首页>>代码示例>>C#>>正文


C# SQLite.SQLiteConnection.RunInTransaction方法代码示例

本文整理汇总了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)
                {

                }
            }
        }
开发者ID:Ranzu,项目名称:Voluteers-App,代码行数:25,代码来源:JobViewModel.cs

示例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();
     }
 }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:15,代码来源:Dashboard.xaml.cs

示例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();

            }
        }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:17,代码来源:Dashboard.xaml.cs

示例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));
            }
        }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:18,代码来源:Register.xaml.cs

示例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";
            }
开发者ID:sovenga,项目名称:ElectricityApp1,代码行数:41,代码来源:MeterViewModel.cs

示例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));

        }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:28,代码来源:AddAddress.xaml.cs

示例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)
                    {

                    }
                }
            }
开发者ID:sovenga,项目名称:ElectricityApp1,代码行数:25,代码来源:MeterViewModel.cs

示例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));
            }

        }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:37,代码来源:AddRequests.xaml.cs


注:本文中的SQLite.SQLiteConnection.RunInTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。