简体   繁体   English

IMul​​tipleResults:当存储的proc不映射到类型时,如何处理多个结果集?

[英]IMultipleResults: how do I deal with multiple result sets from a stored proc when they don't map to types?

This post on SO answers most of the questions I have (much thanks to Pure.Krome for the thorough response) about how to build a query that returns multiple results. 关于SO的帖子回答了我的大部分问题(非常感谢Pure.Krome的全面答复),有关如何构建可返回多个结果的查询。 However, in the case that I'm working with my tables that are coming back are sort of dependent on how the proc behaves. 但是,如果我正在处理要返回的表,则取决于proc的行为方式。 Can't change the proc. 无法更改该过程。 The results that are coming back are a set of datatables that don't map to types at all (for example, the first table is a mish mash of parts of the Customers table and the Orders table, the second table, if present, will be debugging output, then there might be a third table and so on). 返回的结果是一组根本不映射到类型的数据表(例如,第一个表是Customers表和Orders表的一部分的混杂部分,第二个表(如果存在)将调试输出,那么可能会有第三个表,依此类推)。

Do I have to do this as a dataset/datadapter etc? 我是否必须作为数据集/数据适配器等来执行此操作? Or is this possible with LINQ? 还是使用LINQ可能?

LINQ is an ORM (albeit a fairly simple one), with the "O" being (importantly) "object". LINQ是一个ORM(尽管相当简单),“ O”是(重要地)“对象”。 If you can't predict the layout of the object returned in each grid, then it isn't a good fit for ORM. 如果您无法预测每个网格中返回的对象的布局,那么它就不太适合ORM。

Personally I wouldn't jump from LINQ to DataTable (but maybe I'm just biased against DataTable ;-p) - I would use SqlCommand.ExecuteReader and do my own object (etc) mapping. 我个人不会从LINQ跳到DataTable (但也许我只是偏爱DataTable ;-p)-我将使用SqlCommand.ExecuteReader并进行自己的对象(等)映射。 But maybe it might save time to just use a DataSet ... YMMV etc. 但是也许仅使用DataSet ... YMMV等可以节省时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PostgreSql 调用具有多个结果集的存储过程 - PostgreSql call stored proc with multiple result sets 如何从实体FWK中存储的proc返回3个结果集 - How to return 3 result sets from stored proc in entity FWK 如何处理Nullable <T> 从存储过程返回的类型? - How to handle Nullable<T> types returned from stored proc? 如何使用 IMultipleResults 并从 SQL 存储过程返回 Output 参数? - How can I use IMultipleResults AND return Output Parameters from a SQL Stored procedure? 如何使用 SqlCommand 返回多个结果集? - How do I return multiple result sets with SqlCommand? 当我不关心字典的类型时,如何将字典作为参数传递? - How do I pass a dictionary as a parameter when I don't care about a dictionary's types? 存储过程返回多个结果集时应如何写dbml? - How dbml should be written when a stored procedure returns multiple result sets? 使用ObjectContext从存储过程中检索多个结果集 - Retrieve multiple result sets from a stored procedure using ObjectContext 在Entity Framework数据库优先方法中,如何从存储过程返回多个结果集? - In Entity Framework database-first approach how to return multiple result sets from a stored procedure? 当我处理多种数据类型时,如何处理多个foreach循环 - How can I deal with multiple foreach loops when I'm working with multiple data types
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM