There is an entity Effort that has a property List and a property AdType
We have several adTypes enum objects and specialLists enum objects to select IList<Effort>
I do it in this way:
return NHibernateSession.QueryOver<Effort>()
.JoinQueryOver(effort => effort.AdType)
.WhereRestrictionOn(adType => adType.Id)
.IsIn(adTypes.Select(adt => (long)adt).ToList())
.Clone()
.JoinQueryOver(effort => effort.List)
.WhereRestrictionOn(list => list.Id)
.IsIn(specialLists.Select(sl => (long)sl).ToList())
.List<Effort>();
as u can see I use a strange Clone() method that doesn’t have any description. It works great.
In what way do you use QueryOver for such queries?
.JoinQueryOver(effort => effort.AdType)will return a QueryOver with a subtype, hereAdTypeIQueryOver<Effort, Adtype>instead of the originalIQueryOver<Effort, Effort>. The first generic argument is the queryType and the second the type on which the methods are operating on. If you clone in between the whole query is copyied and returned as the basequeryIQueryOver<Effort, Effort>.To prevent the QueryOver to switch to the subtype there is JoinAlias which creates an alias instead of descending.
not that if you only Restrict on the Id of adtype and listtype then