BLToolkit: Multiple resultsets?

梦想与她 提交于 2019-12-05 16:24:21

It turns out it was really simple. :)

Here's how you return multiple unrelated resultsets using BLToolkit.

List<Apple> apples = new List<Apple>();
List<Orange> oranges = new List<Orange>();

MapResultSet[] sets = new MapResultSet[2];
sets[0] = new MapResultSet(typeof(Apple), apples);
sets[1] = new MapResultSet(typeof(Orange), oranges); //Make sure both lists are added

//Skip adding relations

using (DbManager db = new DbManager())
{
    db
        .SetSpCommand("usp_Fruit_GetBySomething",
            db.Parameter("someParam", someParam))
        .ExecuteResultSet(sets);
}

foreach(Apple apple in apples)
{
  profit(apple);
}

foreach(Orange orange in oranges)
{
  profit(orange);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!