views:

1163

answers:

2

Hi, I may be completely blind and stupid, but I cannot find any method generated by ADO.NET Entity Data Model that would somehow delete rows from my table. I didn't want to create a custom query. So how do I do that? Please help.

I don't have the method DeleteOnSubmit... don't know why. This is the code I wanted to use.

var deleteOrderDetails =
from details in db.OrderDetails
where details.OrderID == 11000
select details;

foreach (var detail in deleteOrderDetails)
{
db.OrderDetails.DeleteOnSubmit(detail);
}

db.SubmitChanges();
+2  A: 

A couple of alterations needed:

db.DeleteObject(detail);

and

db.SaveChanges();

Kindness,

Dan

PS: Have you been using Linq to SQL and then swapped to the Entity Framework?

Daniel Elliott
Yes. That would be the case. Also - can I delete multiple rows at once by this?
Trimack
You can do mutiple delete objects per SaveChanges, yes :)
Daniel Elliott
No, what I meant was if I could do dv.DeleteObject(deleteOrderDetails);??
Trimack
I don't believe so.
Daniel Elliott
A: 

What if i have to delete all rows form table?

Izhar
I'm also looking for this too
Junior Mayhé