2

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

2 Answers 2

2

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)
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.