Bulk deletion in Entities Framework 4

entity-framework

Question

I wish to know if there is a good way to do a bulk delete or delete multiple rows using the Entities Framework 4. I can't seam to find a DeleteAll command. The only one that is available is DeleteObject() which only takes one entity, I would like to perform a delete on a list of entities.Is there a better way than to loop trough the list? I did see an article that used ExecuteStoreQuery and created some sql that would perform the delete. Is there a better way than to perform any of these two options Please advice what is the best way to perform this action.

1
8
4/6/2010 10:53:19 PM

Accepted Answer

There isn't an elegant way to do this as of yet. You're correct, you'll have to loop through the list.

This SO post has some good discussions on the topic: How do I delete multiple rows in Entity Framework (without foreach)

3
5/23/2017 12:13:31 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow