Is there any way to accomplsig something simple as this using EF Code First
DELETE FROM Order WHERE OrderDate >= @minOrderDate AND OrderDate >= @maxOrderDate
I have a table of which I would like to delete at least 10.000 records. I think it would be rather inefficient to retrieve all records first before I can delete them using a for-each loop.
You can use
ctx.Database.ExecuteSqlCommand(sqlDeleteStatement,
new SqlParameter("@minOrderDate", minDate),
new SqlParameter("@maxOrderDate", maxDate));
NOTE: The accepted answer does not compile.