开发者

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>();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜