标题几乎说明了我要做的事情。我有选择案例的nhibernate hql
select application.SubmissionDate, count(candidates)
from Application as application group by application.SubmissionDate
我想将此查询的返回值放入一个名为'CountPerDay'对象的对象(不在nhibernate映射文件中)
class CountPerDay {
public DateTime Date,
public int Count
}
nHibernate是否有一些内置的功能/方法?
答案 0 :(得分:2)
你应该看一下Ad-hoc mapping的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>();