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


C# SQLiteConnection.Delete方法代码示例

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


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

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

示例2: DeleteGrade

 public static void DeleteGrade(int id)
 {
     using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
     {
         Student m = (from p in db.Table<Student>()
                      where p.Id == id
                      select p).FirstOrDefault();
         if (m != null)
             db.Delete(m);
     }
 }
开发者ID:DarryStonem,项目名称:SQLiteUWP-Sample,代码行数:11,代码来源:Database.cs

示例3: DeleteStudentByEmail

 /// <summary>
 /// Delete a student by email
 /// </summary>
 /// <param name="email">Student Email</param>
 public static void DeleteStudentByEmail(string email)
 {
     using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
     {
         Student m = (from p in db.Table<Student>()
                      where p.Email == email
                      select p).FirstOrDefault();
         if (m != null)
             db.Delete(m);
     }
 }
开发者ID:DarryStonem,项目名称:SQLiteUWP-Sample,代码行数:15,代码来源:Database.cs

示例4: DeleteStudents

 /// <summary>
 /// Delete all students in the database
 /// </summary>
 /// <param name="students"></param>
 public static void DeleteStudents(IEnumerable<Student> students)
 {
     using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
     {
         foreach (var item in students)
         {
             db.Delete(item);
         }
     }
 }
开发者ID:DarryStonem,项目名称:SQLiteUWP-Sample,代码行数:14,代码来源:Database.cs

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

示例6: CreateDatabase

        private async static Task<ObservableCollection<ItemsNews>> CreateDatabase(ObservableCollection<ItemsNews> itemsNews, string path)
        {
            ObservableCollection<ItemsNews> resultItems = new ObservableCollection<ItemsNews>();
            if (!HttpRequest.HasInternet()) return await GetAllNews(path);
            using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), path))
            {
                var maxCountNews = 25;
                var c = db.CreateTable<ItemsNews>();
                var info = db.GetMapping(typeof(ItemsNews));

                var items = (from p in db.Table<ItemsNews>()
                             select p).ToList();

                var itemsCount = items.Count;

                if (itemsCount == 0)
                {
                    foreach (var item in itemsNews)
                    {
                        resultItems.Add(item);
                    }
                }

                if (itemsCount > maxCountNews && itemsCount != 0)
                {
                    for (int i = itemsNews.Count-1; i > maxCountNews; i--)
                    {
                        var lasts = itemsNews[i];
                        itemsNews.Remove(lasts);
                        db.Delete(lasts);
                    }
                }
                db.InsertOrReplaceAll(itemsNews);
                var resultColl = (from p in db.Table<ItemsNews>()
                                  select p).ToList();
                return new ObservableCollection<ItemsNews>(resultColl);
            }
        }
开发者ID:Romaxaqaz,项目名称:Onliner,代码行数:38,代码来源:SQLiteDB.cs


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