OneFineDay
OneFineDay

Reputation: 9024

Delete with where clause, Entity Framework 4.0

I am trying to delete all records with a certain field.

db.ExecuteStoreQuery(Of Personnel)("Delete From Personnel Where clientId = @clientId", sqlP)

I have seen example where they used;

db.Database.ExecuteSqlCommand("DELETE FROM ...", someParameter);

But I don't have the Database member on my context. How can I achieve this with an sql string like above?

Upvotes: 0

Views: 489

Answers (1)

David Tansey
David Tansey

Reputation: 6023

There are two type of contexts with EF. It looks like you are using type ObjectContext which does not have the Database property and thus does not have the ExecuteSqlCommand method.

With ObjectContext the related method would be ExecuteStoreCommand().

MSDN

Upvotes: 2

Related Questions