开发者

BLToolkit: Multiple resultsets?

I haven't found a way to retrieve two lists of objects from an SP with two select statements. Is it possible wit开发者_JAVA百科h BLToolkit, or can only hierarchical data be fetched in such a manner?

I'm trying to replace a dataset containing two unrelated tables.


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜