EF6 stored procedure with no results

c# entity-framework-6 sql sql-server-2008-r2

Question

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

Accepted Answer

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

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



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why