Question

I have to delete all rows of a model with condition fkey_id = 1 What 's the better mode?

Was it helpful?

Solution

The fast way is to use batch commands in pure ADO.NET or a stored procedure.
Entity Framework does not support batch execution and deleting the records not attached to context.
The common way to delete using Entity Framework is to explicitly load the collection of objects associated with the fkey_id == 1 and call the delete method.

OTHER TIPS

Agree completely with Devart, for batch Deletes/Updates use standard SQL.

If you are using .NET 4.0 the ObjectContext has some new methods for calling directly.

In particular:

ObjectContext.ExecuteStoreCommand(string commandText, params object[] parameters)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top