Beispiel #1
0
        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();
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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();
        }