Hi all. I am trying to query a table that looks like this
CatalogProduct
- CatalogId - FK to Catalog
- ProductId - FK to Product
The product table has a ParentProductId which is an FK to itself.
using the NHibernate criteria API, i need to get a list of CatalogProducts where the CatalogId is and the ProductId is the Product.ParentProductId (not Product.ProductId).
This is my query, which gives me exceptions:
ICriteria criteria = session.CreateCriteria<CatalogProduct>()
.CreateAlias("Product", "pr")
.CreateAlias("pr.ParentProduct","ppr")
.Add(Restrictions.Eq("ppr.ProductId", productId))
.Add(Restrictions.Eq("Catalog.CatalogId", catalogId));
InnerException = {"The multi-part identifier \"ppr2_.ProductId\" could not be bound."}