Page 1 of 1

DeleteObject for more than one element

Posted: Tue 06 Apr 2010 13:09
by lancelotti
It works...

Code: Select all

var tmp = db.Relacionadas.First(r => r.NoticiaId == noticia.Id);
db.DeleteObject(tmp);

But it not.

Code: Select all

var tmp = db.Relacionadas.Where(r => r.NoticiaId == noticia.Id);
db.DeleteObject(tmp);
It I try .First() / .Single() ou etc, it works, but if I try to delete all objects in relation .Any() / .ToList() / .Select(), it doesn't.

I got this error in the second case
The object cannot be deleted because it was not found in the ObjectStateManager.

Any idea? Tks.

Posted: Thu 08 Apr 2010 08:55
by AndreyR
The DeleteObject method does not support batch deleting.
More information is available here:
http://msdn.microsoft.com/en-us/library ... bject.aspx