我们如何在实体框架6.1.3中调用SQL存储过程?

时间:2015-08-17 01:39:19

标签: stored-procedures entity-framework-6

我们尝试通过模型添加SP,但在将SP添加到模型后,会生成以下代码并导致内置错误。我们无法建立项目。请查找以下代码(Context.cs文件)以供参考。请帮助我们。

public virtual ObjectResult<Usp_GetAppUsers_Result> Usp_GetAppUsers(string displayName, string userName, string userPassword, Nullable<int> orgBranchID, string activeStatus)
        {
            var displayNameParameter = displayName != null ?
                new ObjectParameter("DisplayName", displayName) :
                new ObjectParameter("DisplayName", typeof(string));

            var userNameParameter = userName != null ?
                new ObjectParameter("UserName", userName) :
                new ObjectParameter("UserName", typeof(string));

            var userPasswordParameter = userPassword != null ?
                new ObjectParameter("UserPassword", userPassword) :
                new ObjectParameter("UserPassword", typeof(string));

            var orgBranchIDParameter = orgBranchID.HasValue ?
                new ObjectParameter("OrgBranchID", orgBranchID) :
                new ObjectParameter("OrgBranchID", typeof(int));

            var activeStatusParameter = activeStatus != null ?
                new ObjectParameter("ActiveStatus", activeStatus) :
                new ObjectParameter("ActiveStatus", typeof(string));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Usp_GetAppUsers_Result>("Usp_GetAppUsers", displayNameParameter, userNameParameter, userPasswordParameter, orgBranchIDParameter, activeStatusParameter);
        }

0 个答案:

没有答案