public static void ClearHistory() { using (var context = new BingeContext()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); } }
/// <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(); } }
public static IEnumerable <CookieBinge> GetRecentBinges(int numberToRetrieve) { using (var context = new BingeContext()) { return(context.Binges .OrderByDescending(b => b.TimeOccurred) .Take(numberToRetrieve).ToList()); } }
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(); } }