在.net core中使用多个结果集

编程入门 行业动态 更新时间:2024-10-28 07:33:55
本文介绍了在 core中使用多个结果集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用存储过程检索结果时,如何在核心的视图模型中检索和存储多个结果集

While retrieving the results using stored procedure how can I retrieve and store multiple result set in view model in core

例如从存储过程中,我将返回以下两个查询的记录

For e.g. from stored procedure I am returning records for below two queries

Select * LMS_Survey Select * from LMS_SurveyQuestion Select * from LMS_SurveyQuestionOptionChoice

及以下是两个表的视图模型

and below is view model for two tables

public class LMS_SurveyTraineeViewModel { public LMS_SurveyDetailsViewModel SurveyDetailsViewModel { get; set; } public LMS_SurveyQuestionsViewModel SurveyQuestionsViewModel { get; set; } public LMS_SurveyQuestionOptionChoiceViewModel SurveyQuestionOptionChoiceViewModel { get; set; } }

这就是我执行存储过程的方式

This is how I am executing the stored procedure

public List<LMS_SurveyTraineeViewModel> GetTraineeSurvey(int surveyID) { try { List<LMS_SurveyTraineeViewModel> modelList = new List<LMS_SurveyTraineeViewModel>(); modelList = dbcontext.Set<LMS_SurveyTraineeViewModel>().FromSql("LMSSP_GetTraineeSurvey @surveyID = {0},@LanguageID = {1}", surveyID, AppTenant.SelectedLanguageID).ToList(); return modelList; } catch (Exception ex) { throw ex; } }

如何在视图模型中使用存储过程存储多个结果集?

How can stored the multiple result set using stored procedure in view model ?

推荐答案

当前,EF Core不支持此功能.有一个未解决的问题可以解决这个问题.

Currently, EF Core doesn't not support this. There is an open issue to address this.

github/aspnet/EntityFramework/issues/8127

更新2018年9月12日:即使对于EF Core 3.0版,这仍然不是EF Core的优先事项;因此,在有多个结果的情况下,最好使用Dapper或纯ADO.NET

Update 12th Sep 2018: This is still not a priority for EF Core even for release 3.0; so best use Dapper or plain ADO.NET when you have multiple results scenario

更新2020年6月25日:EF Core仍在积压中,即使是5.0版;因此,在有多个结果的情况下,最好使用Dapper或纯ADO.NET

Update 25th Jun 2020: still on the backlog for EF Core even for release 5.0; so best use Dapper or plain ADO.NET when you have multiple results scenario

更多推荐

在.net core中使用多个结果集

本文发布于:2023-11-04 11:26:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557803.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   net   core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!