return objects that are not in the mapping file from nhibernate hql
the title says pretty much what I'm trying to do. I have nhibernate hql with select case
select application.SubmissionDate, count(candidates)
from Application as application group by application.SubmissionDate
I would like to have the return values from this query into an object (which is not in nhibernate mapping file) called 'CountPerDay' object
class CountPerDay {
public DateTime Date,
public int Count
}
does nHibernate has sort of bu开发者_如何学Cild in feature /methods to do this?
You should take a look at Ad-hoc mapping for NHibernate:
string hql = @"select application.SubmissionDate as Date, count(candidates) as Count
from Application as application
group by application.SubmissionDate";
var count = session.CreateQuery(hql)
.SetResultTransformer(Transformers.AliasToBean(typeof(CountPerDay)))
.List<CountPerDay>();
精彩评论