コード例 #1
0
        public override void DeleteList()
        {
            using var dbContext = new SQLiteDbContext(DbFilename);
            var blogPostsToDelete = dbContext.BlogPosts.ToList();

            dbContext.BlogPosts.RemoveRange(blogPostsToDelete);
            dbContext.SaveChanges();
        }
コード例 #2
0
 public override void ReadList()
 {
     using var dbContext = new SQLiteDbContext(DbFilename);
     foreach (var blogPost in dbContext.BlogPosts)
     {
         ReadBlogPosts.Add(blogPost);
     }
 }
コード例 #3
0
 public override void CreateList()
 {
     using var dbContext = new SQLiteDbContext(DbFilename);
     dbContext.BlogPosts.AddRange(BlogPosts.List);
     dbContext.SaveChanges();
 }
コード例 #4
0
 public override void Prepare()
 {
     using var dbContext = new SQLiteDbContext(DbFilename);
     dbContext.Database.EnsureCreated();
 }