I\'d like to have nHibernate return a strongly typed list from a CreateQuery invocation using HQL.
We\'d like a strongly typed list of \"MyType\" returned, but we\'d li
Here is what you need to do:
IList<MyObj> reults = Session.CreateQuery("select r.feedname as feedname, count(r.feedurl) as feedcount from rsssubscriptions r group by r.feedname")
.SetResultTransformer(NHibernate.Transform.Transformers.AliasToBean(typeof(myobj)))
.List<MyObj>();
And then define the MyObj type like this:
public class MyObj
{
public virtual long feedcount { get; set; }
public virtual string feedname { get; set; }
}
The property names of the above type must be the same as the aliases of your returned properties and all properties must be virtual.
Read the following post on more info on what you can do with the SetResultTransformer() method: http://www.junasoftware.com/blog/nhibernate-setresulttransformer-and-dto.aspx