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


C# SQLiteConnection.Update方法代码示例

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


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

示例1: SaveOptions

 public static int SaveOptions(Options options)
 {
     using (SQLiteConnection conn = new SQLiteConnection(dbLocation))
       {
     return conn.Update(options);
       }
 }
开发者ID:spaceyjase,项目名称:timer,代码行数:7,代码来源:OptionsRepository.cs

示例2: UpdateJobStatus

        public JobDto UpdateJobStatus(int jobId, string status)
        {
            using (var databaseConnection = new SQLiteConnection(new SQLitePlatformWP8(), this.DatabaseFilePath))
            {
                var job = databaseConnection.Table<Job>().FirstOrDefault(j => j.Id == jobId);

                if (job == null)
                {
                    throw new Exception("Unable to find Job in database!");
                }

                job.JobStatus = status;
                databaseConnection.Update(job);

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

示例3: 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

示例4: AddOrUpdateGradeToStudent

        public static void AddOrUpdateGradeToStudent(Grade grade)
        {
            using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
            {

                if (grade.Id == 0)
                {
                    // New
                    db.Insert(grade);
                }
                else
                {
                    // Update
                    db.Update(grade);
                }
            }
        }
开发者ID:DarryStonem,项目名称:SQLiteUWP-Sample,代码行数:17,代码来源:Database.cs

示例5: AddOrUpdateStudent

        /// <summary>
        /// With a Student Id == 0, will create a new student
        /// </summary>
        /// <param name="student"></param>
        public static void AddOrUpdateStudent(Student student)
        {
            // Create a new connection
            using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
            {

                if (student.Id == 0)
                {
                    // New
                    db.Insert(student);
                }
                else
                {
                    // Update
                    db.Update(student);
                }
            }
        }
开发者ID:DarryStonem,项目名称:SQLiteUWP-Sample,代码行数:22,代码来源:Database.cs

示例6: SavePerson

        public static void SavePerson(Person person)
        {
            // Create a new connection
            using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
            {
                // Activate Tracing
                db.TraceListener = new DebugTraceListener();

                if (person.Id == 0)
                {
                    // New
                    db.Insert(person);
                }
                else
                {
                    // Update
                    db.Update(person);
                }
            }
        }
开发者ID:TheNewDaysDawn,项目名称:UWP-SQLite-Sample,代码行数:20,代码来源:Dal.cs

示例7: SaveItem

        public string SaveItem(MediaViewModel item)
        {
            string result = string.Empty;
            using (var db = new SQLiteConnection(App.SQLITE_PLATFORM, App.DB_PATH))
            {
                try
                {
                    var existingItem = (db.Table<Media>().Where(
                        c => c.Id == item.Id)).SingleOrDefault();

                    if (existingItem != null)
                    {
                        existingItem.Id = item.Id;
                        existingItem.Name = item.Name;
                        existingItem.VidOrPic = item.VidOrPic;

                        int success = db.Update(existingItem);
                    }
                    else
                    {
                        int success = db.Insert(new Media()
                        {
                            Id = item.Id,
                            Name = item.Name,
                            CreationDate = item.CreationDate,
                            VidOrPic = item.VidOrPic
                        });
                    }
                    result = "Success";
                }
                catch
                {
                    result = "This item was not saved.";
                }
            }
            return result;
        }
开发者ID:Kinani,项目名称:TimelineMe-deprecated-,代码行数:37,代码来源:MediaViewModel.cs


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