Exemple #1
0
        public static void Delete(Guitar guitar)
        {
            using (GuitarContext context = new GuitarContext())
            {
                context.Database.Log = Console.WriteLine;

                context.Entry(guitar).State = EntityState.Deleted;
                context.SaveChanges();
            }
        }
Exemple #2
0
        public static Guitar Update(Guitar guitar)
        {
            using (var context = new GuitarContext())
            {
                context.Database.Log = Console.WriteLine;

                context.Entry(guitar).State = EntityState.Modified;
                context.SaveChanges();

                return(guitar);
            }
        }
Exemple #3
0
        public static void Delete(int id)
        {
            using (GuitarContext context = new GuitarContext())
            {
                Guitar guitarToDelete = (from guitar in context.Guitars
                                         where guitar.GuitarId == id
                                         select guitar).Single();


                context.Entry(guitarToDelete).State = EntityState.Deleted;
                context.SaveChanges();
            }
        }