nhibernate - QueryOver child collections giving cartesian products -
i have domain trying query looks (with other unimportant properties omitted) , related mapping:
// domain: public class order { public virtual site release { get; set;} public virtual site return { get; set;} } public class site { public virtual calendar { get; set; } } public class calendar { public virtual ilist<holidaydate> holidays { get; set; } } // mapping: public class ordermap : classmap<order> { public ordermap() { references(x => x.release); references(x => x.return); } } public class sitemap : classmap<site> { public sitemap() { component(x => x.calendar, component => { component.map(x => x.workingdays); component.hasmany(x => x.holidays).cascade.alldeleteorphan(); }); } }
i query orders, having specific status , joining both release
, return
release
, join in calendar
(which component-mapped entity) , calendar join in holidays (left outer join). have tried few different ways, try join in holidays, cartesian product (i assume both sites holidays).
i did attempt futures (like this):
var orders = session.queryover<order>() .where(x => x.status == selected.status) .future<order>(); session.queryover<order>() .joinalias(x => x.release, () => release, jointype.leftouterjoin) .joinalias(() => release.calendar.holidays, () => holiday, jointype.leftouterjoin) .where(x => x.status == selected.status) .future<order>(); var output = orders.tolist();
...but still more holidays expect. if can query figured out, filter holidays date
> todays date.
is @ possible perform query or there option have missed?