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


C# SQLiteConnection.RunInTransaction方法代码示例

本文整理汇总了C#中SQLiteConnection.RunInTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.RunInTransaction方法的具体用法?C# SQLiteConnection.RunInTransaction怎么用?C# SQLiteConnection.RunInTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLiteConnection的用法示例。


在下文中一共展示了SQLiteConnection.RunInTransaction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Insert

        public void Insert(Student student)
        {
            var sqlPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "StudentDB.sqlite");

            using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformWinRT(), sqlPath))
            {
                conn.RunInTransaction(() =>
                {
                    conn.Insert(student);
                });
            }
        }
开发者ID:Adaok,项目名称:SqLite_Windows10,代码行数:12,代码来源:Database.cs

示例2: AddJob

        public JobDto AddJob(Job job)
        {
            using (var databaseConnection = new SQLiteConnection(new SQLitePlatformWP8(), this.DatabaseFilePath))
            {
                databaseConnection.RunInTransaction(() =>
                {
                    databaseConnection.Insert(job);
                });
            }

            return Mapper.Map<JobDto>(job);
        }
开发者ID:gep13,项目名称:WindowsPhoneSample,代码行数:12,代码来源:JobRepository.cs

示例3: Delete

        public void Delete(int Number)
        {
            var sqlPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "StudentDB.sqlite");

            using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformWinRT(), sqlPath))
            {
                var existingconact = conn.Query<Student>("select * from Students where Number =" + Number).FirstOrDefault();
                if (existingconact != null)
                {
                    conn.RunInTransaction(() =>
                    {
                        conn.Delete(existingconact);
                    });
                }
            }
        }
开发者ID:Adaok,项目名称:SqLite_Windows10,代码行数:16,代码来源:Database.cs

示例4: Update

        public void Update(Student student)
        {
            var sqlPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "StudentDB.sqlite");

            using (SQLiteConnection conn = new SQLiteConnection(new SQLitePlatformWinRT(), sqlPath))
            {
                var existingStudent = conn.Query<Student>("select * from Students where Number =" + student.Number).FirstOrDefault();

                if (existingStudent != null)
                {
                    existingStudent.Name = student.Name;
                    existingStudent.Number = student.Number;
                    existingStudent.Department = student.Department;

                    conn.RunInTransaction(() =>
                    {
                        conn.Update(existingStudent);
                    });
                }
            }
        }
开发者ID:Adaok,项目名称:SqLite_Windows10,代码行数:21,代码来源:Database.cs

示例5: DatabaseCleanUp

        // Same method used to clean up the
        // database.
        private void DatabaseCleanUp (SQLiteConnection cnn)
        {
            // TODO: temporal method to clear old
            // draft entries from DB. It should be removed
            // in next versions.
            cnn.Table <TimeEntryData> ().Delete (t => t.State == TimeEntryState.New);

            // TODO: temporal method to clear
            // data with wrong workspace defined.
            var user = cnn.Table <UserData> ().FirstOrDefault ();
            if (user != null && user.DefaultWorkspaceId != Guid.Empty) {
                var tableNames = new List<string>  { cnn.Table<TimeEntryData>().Table.TableName,
                                                     cnn.Table<ClientData>().Table.TableName,
                                                     cnn.Table<ProjectData>().Table.TableName,
                                                     cnn.Table<TagData>().Table.TableName,
                                                     cnn.Table<TaskData>().Table.TableName
                                                   };
                cnn.RunInTransaction (() =>  {
                    foreach (var tableName in tableNames) {
                        var q = string.Concat ("UPDATE ", tableName ," SET WorkspaceId = '", user.DefaultWorkspaceId ,"' WHERE WorkspaceId = '", Guid.Empty, "'");
                        cnn.Execute (q);
                    }
                });
            }
        }
开发者ID:eatskolnikov,项目名称:mobile,代码行数:27,代码来源:DataStoreTest.cs

示例6: DeleteItem

        public string DeleteItem(int itemId)
        {
            string result = string.Empty;
            using (var dbConn = new SQLiteConnection(App.SQLITE_PLATFORM, App.DB_PATH))
            {
                var existingItem = dbConn.Query<Media>("select * from Media where Id =" + itemId).FirstOrDefault();
                if (existingItem != null)
                {
                    dbConn.RunInTransaction(() =>
                    {
                        dbConn.Delete(existingItem);

                        if (dbConn.Delete(existingItem) > 0)
                        {
                            result = "Success";
                        }
                        else
                        {
                            result = "This item was not removed";
                        }

                    });
                }

                return result;
            }
        }
开发者ID:Kinani,项目名称:TimelineMe-deprecated-,代码行数:27,代码来源:MediaViewModel.cs


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