3
votes

My environment is VS 2012, C#, EF6 and SQL Server 2008 R2.

I want to execute a stored procedure to delete records with no return value using the pattern:

dataContext.Database.SqlQuery<return type>("name", parameter)

If there are no results returned e.g. with NO COUNT ON what should I set as the return type? Seems that it should be simple but I cannot find an answer anywhere.

I tried dataContext.Database.SqlQuery("name", parameter) but that returns a compile error: The best overloaded method match for 'System.Data.Entity.Database.SqlQuery(System.Type, string, params object[])' has some invalid arguments

1

1 Answers

8
votes

Use ExecuteSqlCommand instead of SqlQuery if you don't need to query some data:

dataContext.Database.ExecuteSqlCommand("name", parameter)