コード例 #1
0
 public IEnumerable <VideoGame> GetAll()
 {
     using (var context = new VideoGamesDataContext(_connectionString))
     {
         return(context.VideoGames.ToList());
     }
 }
コード例 #2
0
 public void AddGame(VideoGame videoGame)
 {
     using (var context = new VideoGamesDataContext(_connectionString))
     {
         context.VideoGames.InsertOnSubmit(videoGame);
         context.SubmitChanges();
     }
 }
コード例 #3
0
 public void UpdateGame(VideoGame videoGame)
 {
     using (var context = new VideoGamesDataContext(_connectionString))
     {
         context.VideoGames.Attach(videoGame);
         context.Refresh(RefreshMode.KeepCurrentValues, videoGame);
         context.SubmitChanges();
     }
 }
コード例 #4
0
 public void DeleteGame(int gameId)
 {
     using (var context = new VideoGamesDataContext(_connectionString))
     {
         //var game = context.VideoGames.FirstOrDefault(g => g.Id == gameId);
         //context.VideoGames.DeleteOnSubmit(game);
         //context.SubmitChanges();
         context.ExecuteCommand("DELETE FROM VideoGames WHERE Id = {0}", gameId);
     }
 }