NHibernate Fluent 分组依据

发布于 2024-12-07 21:04:07 字数 1496 浏览 1 评论 0原文

我有这个 nhibernate 标准:

       criteria.Add(Subqueries.PropertyIn("Id", DetachedCriteria.For<ReconItemReconSide>()
            .SetProjection(Projections.ProjectionList()
            .Add(Projections.GroupProperty("ReconItemFk"))
            .Add(Projections.Min("ReconciliationSideFk")))
            .Add(Expression.In(Projections.Property("ReconItemFk"), items))
            ));

- 这成为这个查询(我已经从外部选择中删除了一些字段以最小化此处的长度):

SELECT this_.Id                        as Id8_0_
FROM   CI.BM_RECONCILIATION_SIDE this_
WHERE  this_.Id in (SELECT   this_0_.BM_RECON_ITEM               as y0_,
                         min(this_0_.BM_RECONCILIATION_SIDE) as y1_
                FROM     CI.BM_RECON_ITEM_RECON_SIDE this_0_
                WHERE    this_0_.BM_RECON_ITEM in (345061 /* :p0 */,345877 /* :p1 */)
                GROUP BY this_0_.BM_RECON_ITEM)

问题是我希望内部选择仅选择一个字段(min(this_0_. BM_RECONCILIATION_SIDE)),但 groupby 还会将 groupby-field 添加到选择中。

我希望能够创建一个 groupby 而不必投影 groupby 字段本身。 查询应该类似于:

SELECT this_.Id                        as Id8_0_
FROM   CI.BM_RECONCILIATION_SIDE this_
WHERE  this_.Id in (SELECT   
                         min(this_0_.BM_RECONCILIATION_SIDE) as y1_
                FROM     CI.BM_RECON_ITEM_RECON_SIDE this_0_
                WHERE    this_0_.BM_RECON_ITEM in (345061 /* :p0 */,345877 /* :p1 */)
                GROUP BY this_0_.BM_RECON_ITEM)

知道如何解决这个问题吗?

I have this nhibernate criteria:

       criteria.Add(Subqueries.PropertyIn("Id", DetachedCriteria.For<ReconItemReconSide>()
            .SetProjection(Projections.ProjectionList()
            .Add(Projections.GroupProperty("ReconItemFk"))
            .Add(Projections.Min("ReconciliationSideFk")))
            .Add(Expression.In(Projections.Property("ReconItemFk"), items))
            ));

-which becomes this query (I have removed some of the fields from the outer select to minimize the length here):

SELECT this_.Id                        as Id8_0_
FROM   CI.BM_RECONCILIATION_SIDE this_
WHERE  this_.Id in (SELECT   this_0_.BM_RECON_ITEM               as y0_,
                         min(this_0_.BM_RECONCILIATION_SIDE) as y1_
                FROM     CI.BM_RECON_ITEM_RECON_SIDE this_0_
                WHERE    this_0_.BM_RECON_ITEM in (345061 /* :p0 */,345877 /* :p1 */)
                GROUP BY this_0_.BM_RECON_ITEM)

The problem is that I want the inner-select to select one field only (min(this_0_.BM_RECONCILIATION_SIDE)), but the groupby also add the groupby-field to the select.

I want to be able to create a groupby without having to project the groupby field itself.
The query should look similar to this:

SELECT this_.Id                        as Id8_0_
FROM   CI.BM_RECONCILIATION_SIDE this_
WHERE  this_.Id in (SELECT   
                         min(this_0_.BM_RECONCILIATION_SIDE) as y1_
                FROM     CI.BM_RECON_ITEM_RECON_SIDE this_0_
                WHERE    this_0_.BM_RECON_ITEM in (345061 /* :p0 */,345877 /* :p1 */)
                GROUP BY this_0_.BM_RECON_ITEM)

Any idea how to solve this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱*していゐ 2024-12-14 21:04:07

好吧,这似乎仍然是 nHib 的未决问题
就像他们总是说的那样 - 欢迎您自己实现它..:)

well, it seems like this is still an open issue with nHib.
like they always say- you're welcome to implement it yourself.. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文