NHibernate HQL:如何使用'distinct'来使用新的对象构造函数?

时间:2011-07-06 22:01:47

标签: nhibernate hql

我需要使用 HQL对象构造函数,例如:

select new SomeClass(i.Id, i.Name) from Item i...

但我需要使用 distinct关键字,因为查询中有更多连接,例如:

select distinct i.Id from Item i

我试过这个:但它只会导致Antlr异常,所以我认为它的语法无效:

select new SomeClass(distinct i.Id, i.Name) from Item i

这可能吗?

1 个答案:

答案 0 :(得分:3)

啊,看起来这样有效:

select distinct new SomeClass(i.Id, i.Name) from Item i...
相关问题