Reputation: 2874
I have an object "Owner" with collection property "Cars". I want to filter Owners based on Cars criteria (Ex: All Owners with Red Cars) and I dont want to query non red cars for SomeOwner.Cars
. So I want one query filter for both parent and collection.
<class name="Owner">
<set name="Cars">
<key column="FK_Owner" />
<one-to-many class="Car" />
</set>
</class>
<class name="Car">
<many-to-one name="Owner" column="FK_Owner" />
</class>
How can I do that?
Upvotes: 0
Views: 176
Reputation: 18909
Car carAlias = null;
var cars = _session.QueryOver<Owner>()
.JoinAlias(x=>Cars,()=>carAlias,JoinType.LeftOuterJoin)
.Where(x=>carAlias.Color=="Red")
.List();
Upvotes: 3