本文介绍了在ExecuteStoreQuery EF中执行存储过程。这是EF中的错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 var params = new object [] {new SqlParameter (@FirstName,Bob)}; 返回this._repositoryContext.ObjectContext.ExecuteStoreQuery< ResultType>(GetByName,params); 但不断收到此错误:和sql profiler: exec sp_executesql N'GetByName',N'@ FirstName nvarchar(100),@ FirstName = N'Bob' 上述ExecuteStoreQuery代码有什么问题?解决方案忽略 params 是保留字的事实 认为您的查询需要: var params = new object [] {new SqlParameter( @FirstName,Bob)}; 返回this._repositoryContext.ObjectContext.ExecuteStoreQuery< ResultType>(exec GetByName @FirstName,params); 还应该说如果proc是数据库和数据模型的标准部分,那么你应该将其导入到您的EDM ,因此可以直接在您的上下文中使用。 trying to execute the stored proc in EF using the following code:var params = new object[] {new SqlParameter("@FirstName", "Bob")};return this._repositoryContext.ObjectContext.ExecuteStoreQuery<ResultType>("GetByName", params);but keep getting this error:and from sql profiler:exec sp_executesql N'GetByName',N'@FirstName nvarchar(100),@FirstName=N'Bob'what is wrong wit the above ExecuteStoreQuery code? 解决方案 Ignoring the fact that params is a reserved word...Think your query needs to be:var params = new object[] {new SqlParameter("@FirstName", "Bob")};return this._repositoryContext.ObjectContext.ExecuteStoreQuery<ResultType>("exec GetByName @FirstName", params);Should also say that if that proc is a standard part of your database and data model then you should import it into your EDM so it's available directly on your context. 这篇关于在ExecuteStoreQuery EF中执行存储过程。这是EF中的错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-26 22:32