没有结果EF6存储过程 [英] EF6 stored procedure with no results

查看:159
本文介绍了没有结果EF6存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的环境是VS 2012年,C#,EF6和SQL Server 2008 R2。

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)

如果没有返回结果如:与 NO指望我应该怎么设置为返回类型?看来,它应该是简单,但我不能在任何地方找到答案。

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.

我试过 dataContext.Database.SqlQuery(名,参数),但返回编译错误:
的最佳重载的方法匹配'System.Data.Entity.Database.SqlQuery(System.Type的,字符串params对象[] )有一些无效参数

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

推荐答案

使用的 ExecuteSqlCommand 代替的 类SqlQuery 如果不这样做需要查询一些数据:

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

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

这篇关于没有结果EF6存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆