我需要使用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
这可能吗?
最佳答案
啊,看起来这个可行:
select distinct new SomeClass(i.Id, i.Name) from Item i...
关于NHibernate HQL : How to use the new object constructor with 'distinct' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6603608/