如何从实体框架中的存储过程中获取结果+数据库优先

问题描述 投票:0回答:1

我正在创建Web api并首先使用实体​​框架数据库并使用存储过程。

存储过程返回表中的结果列并返回值(0或1)。在C#代码中,通过使用存储过程,我想显示结果列。但这没有发生。

下面是我的Web API代码

public async Task<GetRequestDetailsResponse> FetchPASCodeDetail(string SearchField, string SearchValue )
        {
            GetRequestDetailsResponse getRequestDetailsResponse = new GetRequestDetailsResponse();

            getRequestDetailsResponse = context.sp_GetRequestDetails(SearchField, SearchValue) //here i am getting the exception - can not implicitly convert int to GetRequestDetailsResponse 

            return getRequestDetailsResponse
        }

enter image description here

所以我想显示结果列而不是返回值。

TIA

c# entity-framework-6 entity-framework-4
1个回答
0
投票

context.sp_GetRequestDetails是什么样的?您是否生成了它以返回复杂类型?

另请参见:Stored procedure in Entity Framework database first approach

© www.soinside.com 2019 - 2024. All rights reserved.