Deleting bulk objects in DataContext
Can't i delete bulk objects like
Lis开发者_高级运维t<Person> prn = new List<Person>();
prn.Add(new Person { Id = "P007", name = "Andrew"});
prn.Add(new Person { Id = "P009", name = "Bernold"});
prn.Add(new Person { Id = "P010", name = "Hare"});
PersonDB.Persons.DeleteAllOnSubmit(prn);
PersonDB.SubmitChanges();
I receive error
Cannot remove an entity that has not been attached.
Try attaching the objects to the context before deleting:
PersonDB.Persons.AttachAll(prn, true);
精彩评论