问题
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:
Use ExecuteSqlCommand instead of SqlQuery if you don't need to query some data:
dataContext.Database.ExecuteSqlCommand("name", parameter)
来源:https://stackoverflow.com/questions/21043585/ef6-stored-procedure-with-no-results