tags:

views:

27

answers:

1

Can't i delete bulk objects like

List<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.
+1  A: 

Try attaching the objects to the context before deleting:

PersonDB.Persons.AttachAll(prn, true);
Darin Dimitrov
For me AttachAll(prn,false) is working,when i set true,it throws error.
udana