Nhibernate Queryover With Leftjoins
This thing is keeping me busy for days and I hope someone of the NHibernate gurus can help me out. I've got a query set up which is working in SQL Server and I want to get the same
Solution 1:
Here is a draft of the solution... First the subquery:
var subquery = QueryOver
.Of<Tag>()
.Where(t => t.TagCategory == "Jobtype")
.Select(t => t.Name);
And now, we will use the subquery in the withClause:
JobEmployee jobEmployee = null;
Location loc = null;
JobTag jobTag = null;
var list = session
.QueryOver<Job>()
.JoinAlias(x => x.location, () => loc)
.JoinAlias(x => x.tags, () => jobTag, JoinType.LeftOuterJoin,
// instead of this// Restrictions.On(jobTag.name).IsIn(<subquery>))// use thisSubqueries.WhereProperty(() => jobTag.name).In(subquery)
)
.List();
So, we filtered the JOIN using the withClause and Subqueries
Post a Comment for "Nhibernate Queryover With Leftjoins"