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

标签 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

这可能吗?

最佳答案

啊,看起来这个可行:

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/

相关文章:

nhibernate - 无法将 NHibernate.Collection.Generic.PersistentGenericBag 类型的对象强制转换为 List

java - 以日期为数据类型将字符串转换为 "yyy-MM-dd"格式

java - 如何在 HQL 中编写连接查询?

hadoop - Hive 是否依赖/需要 Hadoop?

nhibernate - 流畅的 NHibernate : How to create one-to-many bidirectional mapping?

c# - 冒号 ':' 错误 - Nhibernate 中未设置所有命名参数?

c# - nHibernate 在多个线程上枚举相同的集合

nhibernate - 流畅的 NHibernate - NHibernate.QueryException : could not resolve property

java - 当连接列为字符串时 Hibernate 中发生错误

java - 获取所有属性是否会在幕后进行左连接?