NHibernate HQL: How to use the new object constructor with 'distinct'?

六眼飞鱼酱① 提交于 2019-12-24 00:25:58

问题


I need to use the HQL object constructor feature, e.g:

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

But I also need to use the distinct keyword, as there are joins further down in the query, e.g.:

select distinct i.Id from Item i

I have tried this: but it just causes an Antlr exception, so I assume it's invalid syntax:

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

Is this possible?


回答1:


Ah, it looks like this works:

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


来源:https://stackoverflow.com/questions/6603608/nhibernate-hql-how-to-use-the-new-object-constructor-with-distinct

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!