开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜