views:

230

answers:

2

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

thanks

A: 

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.

Devart
A: 

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)
willbt