[英]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.