public static void Delete(recipe r) { var context = new RecipeContext(); context.recipe.Add(r); //mark the recipe as deleted context.Entry(r).State = EntityState.Deleted; context.SaveChanges(); }
public static void InsertRecipe(recipe r) { RecipeContext context = new RecipeContext(); //assume Recipe is valid context.recipe.Add(r); context.Entry(r).State = EntityState.Added; context.SaveChanges(); }
public static void Update(recipe r) { var context = new RecipeContext(); //add recipe to object to current context context.recipe.Add(r); //Let EF know the book already exists context.Entry(r).State = EntityState.Modified; context.SaveChanges(); }