Пример #1
0
 public static void  Seed(TasksContext DbContext)
 {
     if (!DbContext.Tasks.Any())
     {
         CreateTask(DbContext);
     }
 }
Пример #2
0
 public Repository(TasksContext db)
 {
     this.db = db;
     if (iTaskCache == null)
     {
         iTaskCache = new ConcurrentDictionary <string, iTask>(
             db.Tasks.ToDictionary(c => c.Id.ToString()));
     }
 }
Пример #3
0
        private static async void CreateTask(TasksContext DbContext)
        {
            DbContext.Database.EnsureCreated();

            var items = new List <iTask> {
                new iTask {
                    number = 1, Taska = "Do do homework"
                },
                new iTask {
                    number = 1, Taska = "Do do homework2"
                },
                new iTask {
                    number = 1, Taska = "Do do homework3"
                }
            };

            items.ForEach(s => DbContext.Tasks.Add(s));

            await DbContext.SaveChangesAsync();
        }