コード例 #1
0
 private void PopulateTodos()
 {
     using (var db = new TwoDoContext())
     {
         var todos = db.ToDos.ToList();
         ToDoListView.ItemsSource = todos;
     }
 }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: ericlobdell/TwoDo
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            using (var db = new TwoDoContext())
            {
                db.Database.Migrate();
            }
        }
コード例 #3
0
        private void SeedDB()
        {
            var todos = new List <ToDoItem>
            {
                new ToDoItem {
                    Name = "Groceries", Created = DateTime.Now, Expires = DateTime.Now.AddHours(5)
                },
                new ToDoItem {
                    Name = "Exercise", Created = DateTime.Now, Expires = DateTime.Now.AddHours(7)
                }
            };

            using (var db = new TwoDoContext())
            {
                db.ToDos.AddRange(todos);
                db.SaveChanges();
            }
        }