NHibernate HQL:如何将新的对象构造函数与'distinct'一起使用? [英] NHibernate HQL: How to use the new object constructor with 'distinct'?

查看:189
本文介绍了NHibernate HQL:如何将新的对象构造函数与'distinct'一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

但是我也需要使用 distinct关键字,因为查询中的连接进一步向下,例如:

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

我已经尝试过:但是它只会导致Antlr异常,所以我认为它是无效的语法:

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

这可能吗?

推荐答案

啊,看起来像这样:

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

这篇关于NHibernate HQL:如何将新的对象构造函数与'distinct'一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆