Dear NHibernate experts,
The following query gives me all my categories:
var result = Session.QueryOver(() => cat).List();
.. and by running this query, I get the ones selected (category_x_product table):
int productId = 11;
Category cat = null;
CategoryProduct cp = null;
var subQuery = QueryOver.Of(() => cp)
.Where(() => cp.ProductId == productId)
.Select(Projections.Distinct(Projections.Property(() => cp.CategoryId)));
result = Session.QueryOver(() => cat)
.WithSubquery
.WhereProperty(() => cat.Id).In(subQuery)
.List();
Any way to combine those two queries, so that I get all categories with a boolean value indicating which one was in fact "selected" in the CategoryProduct-query.
Map it to an entity like this, maybe?
CategorySelected
----------------
Category Category { get; set; }
bool IsSelected { get; set;
I've tried to find an answer to this, using QueryOver, but didnt succeed. Is this even possible in a "more or less" simple query? Any help is much appreciated. Thanks!
mikal