Possible Duplicate:
Bulk-deleting in LINQ to Entities
I need to remove some entities by condition. E.g., remove all order items having quantity less than 1:
var orderId = 10; // any order Id
context.OrderItems.RemoveWhere(item => item.OrderId == orderId && item.Quantity < 1.0);
I know, that I can select those items and then remove them one-by-one like this:
var itemsToRemove = context.OrderItems.Where(item => item.OrderId == orderId && item.Quantity < 1.0).ToArray();
foreach (var item in itemsToRemove)
context.OrderItems.Remove(item);
But this is very unlikely, because extra work will take place. Am I missed something?