Hi I am trying to return a collection of building domain.
private long _id;
private string _buildingName;
private IList _rooms;
Why do you need a concrete List
object, when you can do everything you want with an IList
?
If it absolutely has to be a concrete list, you have two options.
First, simply cast the IList
to List
. This will only work if the underlying type is a List
, which I personally doubt.
Second, call the ToList() extension method on it:
Buildings = (List)session.CreateCriteria(typeof(Building)).AddOrder(Order.Asc("buildingName")).List().ToList();
I personally recommend that you do neither and use the IList instead.