24 July 2013

Deleting Record That Handles Concurrency

A simple solution to delete record that handles concurrency:


 public void Delete_Animal_Record(int id)
        {
            Animal animal = Get_Animal_Record(id);
            if (animal != null)
            {
                IEnumerable<AnimalKingdom> animalKingdom = ctx.AnimalKingdoms
                    .Where(y => y.AnimalId = id)
                    .Select(y => y);
                foreach (AnimalKingdom x in z)
                {
                    ctx.AnimalKingdoms.DeleteObject(x);
                }
                ctx.Animals.DeleteObject(animal);
                SaveChanges();
            }
        }

No comments:

Post a Comment