コード例 #1
0
 public static void ClearHistory()
 {
     using (var context = new BingeContext())
     {
         context.Database.EnsureDeleted();
         context.Database.EnsureCreated();
     }
 }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: julielerman/CookieBinge2
 /// <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 context = new BingeContext()) {
         context.Database.EnsureCreated();
         context.Database.Migrate();
     }
 }
コード例 #3
0
 public static IEnumerable <CookieBinge> GetRecentBinges(int numberToRetrieve)
 {
     using (var context = new BingeContext())
     {
         return(context.Binges
                .OrderByDescending(b => b.TimeOccurred)
                .Take(numberToRetrieve).ToList());
     }
 }
コード例 #4
0
        public static void RecordBinge(int count, bool worthIt)
        {
            var binge = new CookieBinge
            {
                HowMany      = count,
                WorthIt      = worthIt,
                TimeOccurred = DateTime.Now
            };

            using (var context = new BingeContext())
            {
                context.Binges.Add(binge);
                context.SaveChanges();
            }
        }