Esempio n. 1
0
 public void Delete()
 {
     using (MusicEntities dc = new MusicEntities())
     {
         tblPieceGenre pieceGenre = dc.tblPieceGenres.FirstOrDefault(pg => pg.PieceId == PieceId && pg.GenreId == GenreId);
         dc.tblPieceGenres.Remove(pieceGenre);
         dc.SaveChanges();
     }
 }
Esempio n. 2
0
        public void Add()
        {
            using (MusicEntities dc = new MusicEntities())
            {
                //Set the properties
                tblPieceGenre pieceGenre = new tblPieceGenre
                {
                    Id      = Guid.NewGuid(),
                    PieceId = PieceId,
                    GenreId = GenreId
                };

                //Add it to the table and save changes
                dc.tblPieceGenres.Add(pieceGenre);
                dc.SaveChanges();
            }
        }