nHibernate Subquery-WhereAll显示"not a delegate type"-error
nHibernate Subquery-WhereAll displays "not a delegate type"-error
我正在尝试创建一个带有子查询的 nHibernate-Query blog-entry。
我的工作 SQL 看起来像这样:
SELECT *
FROM Product
WHERE Id IN (
SELECT p.Id
FROM Product AS p
INNER JOIN ProductSupplier AS ps
ON ps.ProductId LIKE p.Id
WHERE ps.SupplierProductNumber LIKE '102.02-7100'
GROUP BY p.Id
);
我必须按 Id 分组,因为多个供应商可以对同一产品使用相同的 productNumber
。
我的 nHibernate
如下所示:
query.WithSubquery.WhereAll(
p => p.Id ==
QueryOver.Of<Product>()
.JoinAlias(x => x.Suppliers, () => productSupplierAlias)
.Where(() => productSupplierAlias.Product.Id == productAlias.Id)
.Where(() => productSupplierAlias.SupplierProductNumber == searchtext)
.Select(p => p.Id));
但是我的.Select(p => p.Id)
显示
cannot convert lambda expression to type 'nHibernate.Creterian.IProjection[]' because it is not a delegate type
我认为您不应该在这种情况下使用 WhereAll
。
这个有用吗:
query.WithSubquery.WhereProperty(p => p.Id)
.In(QueryOver.Of<Product>()
.JoinAlias(x => x.Suppliers, () => productSupplierAlias)
.Where(() => productSupplierAlias.Product.Id == productAlias.Id)
.Where(() => productSupplierAlias.SupplierProductNumber == searchtext)
.Select(p => p.Id)
);
我正在尝试创建一个带有子查询的 nHibernate-Query blog-entry。
我的工作 SQL 看起来像这样:
SELECT *
FROM Product
WHERE Id IN (
SELECT p.Id
FROM Product AS p
INNER JOIN ProductSupplier AS ps
ON ps.ProductId LIKE p.Id
WHERE ps.SupplierProductNumber LIKE '102.02-7100'
GROUP BY p.Id
);
我必须按 Id 分组,因为多个供应商可以对同一产品使用相同的 productNumber
。
我的 nHibernate
如下所示:
query.WithSubquery.WhereAll(
p => p.Id ==
QueryOver.Of<Product>()
.JoinAlias(x => x.Suppliers, () => productSupplierAlias)
.Where(() => productSupplierAlias.Product.Id == productAlias.Id)
.Where(() => productSupplierAlias.SupplierProductNumber == searchtext)
.Select(p => p.Id));
但是我的.Select(p => p.Id)
显示
cannot convert lambda expression to type 'nHibernate.Creterian.IProjection[]' because it is not a delegate type
我认为您不应该在这种情况下使用 WhereAll
。
这个有用吗:
query.WithSubquery.WhereProperty(p => p.Id)
.In(QueryOver.Of<Product>()
.JoinAlias(x => x.Suppliers, () => productSupplierAlias)
.Where(() => productSupplierAlias.Product.Id == productAlias.Id)
.Where(() => productSupplierAlias.SupplierProductNumber == searchtext)
.Select(p => p.Id)
);