public ScoresViewModel() { using (var db = new UnicornClickerContext()) { this.TopScores = db.GameScores .OrderByDescending(s => s.ClicksPerSecond) .Take(5) .ToList(); } }
public App() { Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync( Microsoft.ApplicationInsights.WindowsCollectors.Metadata | Microsoft.ApplicationInsights.WindowsCollectors.Session); this.InitializeComponent(); this.Suspending += OnSuspending; using (var db = new UnicornClickerContext()) { db.Database.Migrate(); } }
private static void RecordGame(int duration, int clicks) { using (var db = new UnicornClickerContext()) { db.GameScores.Add(new GameScore { Clicks = clicks, Duration = duration, ClicksPerSecond = (double)clicks / duration, Played = DateTime.Now }); db.SaveChanges(); } }