public static void CreateDatabase() { using (var context = new ScoresDataContext(ConnectionString)) { if (!context.DatabaseExists()) { context.CreateDatabase(); } } }
public static IList<Score> GetScores() { IList<Score> scores; using (var context = new ScoresDataContext(ConnectionString)) { scores = (from sco in context.Scores select sco).ToList(); } return scores; }
public static void AddScore(Score score) { using (var context = new ScoresDataContext(ConnectionString)) { if (context.DatabaseExists()) { context.Scores.InsertOnSubmit(score); context.SubmitChanges(); } } }