【问题标题】:NHibernate HQL: How to use the new object constructor with 'distinct'?NHibernate HQL:如何使用带有'distinct'的新对象构造函数?
【发布时间】:2011-07-06 22:01:47
【问题描述】:

我需要使用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

这可能吗?

【问题讨论】:

标签: nhibernate hql


【解决方案1】:

啊,看起来这样可行:

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

【讨论】:

    猜你喜欢
    • 2021-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-05
    • 1970-01-01
    • 1970-01-01
    • 2011-06-24
    • 1970-01-01
    相关资源
    最近更新 更多