我有这个禁止的标准:
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添加到select。
我希望能够创建一个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)
知道如何解决这个问题吗?