How do I convert a non-Generic IList to IList?

前端 未结 7 1826
失恋的感觉
失恋的感觉 2021-02-02 06:20

I have class that wants an IList, but I have a Systems.Collection.IList, coming from an NHibernate quere.

I want to create a method th

7条回答
  •  清歌不尽
    2021-02-02 06:47

    Fredrick is correct. But Nhibernate also has an option to return multiple result sets. For example:

      IList multiResults = session.CreateMultiCriteria()
                    .Add(pageCriteria)
                    .Add(countCriteria)
                    .List();
    

    In the above call there isn't an option to return a typed list. So it has to be casted as mentioned above, like this:

     IList results = ((IList)multiResults[0]).Cast().ToList();
                IList counts = (IList)multiResults[1];
    

提交回复
热议问题