简体   繁体   中英

How to return multiple result in nhibernate using c#

I have one stored procedure which returns multiple result sets in Nhibernate using c# , below is the c# code , but I am not able to return which type because i have 3 result sets of type lure, bait and fly. so any idea on this? or i need to change code.

public somereturn GetData() {
    var query = _session.CreateSQLQuery("exec GetTopProducingStats 
      @userId=:userId");
    query.SetParameter("userId", userId);
    var result = _session.CreateMultiQuery()
        .Add(query.AddEntity(typeof(Lure)))
        .Add(_session.CreateSQLQuery("").AddEntity(typeof(Bait)))
        .Add(_session.CreateSQLQuery("").AddEntity(typeof(Fly)))
        .List();
}

Based on your answer to my comment you can make somereturn be IList

public IList GetData() {
    var query = _session.CreateSQLQuery("exec GetTopProducingStats 
      @userId=:userId");
    query.SetParameter("userId", userId);
    var result = _session.CreateMultiQuery()
        .Add(query.AddEntity(typeof(Lure)))
        .Add(_session.CreateSQLQuery("").AddEntity(typeof(Bait)))
        .Add(_session.CreateSQLQuery("").AddEntity(typeof(Fly)))
        .List();
    return result;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM