Note that there are some explanatory texts on larger screens.

plurals
  1. POQueryOver child collections giving cartesian products
    primarykey
    data
    text
    <p>I have a domain I am trying to query that looks like this (with other unimportant properties omitted) and related mapping:</p> <pre><code>// 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&lt;HolidayDate&gt; Holidays { get; set; } } // Mapping: public class OrderMap : ClassMap&lt;Order&gt; { public OrderMap() { References(x =&gt; x.Release); References(x =&gt; x.Return); } } public class SiteMap : ClassMap&lt;Site&gt; { public SiteMap() { Component(x =&gt; x.Calendar, component =&gt; { component.Map(x =&gt; x.WorkingDays); component.HasMany(x =&gt; x.Holidays).Cascade.AllDeleteOrphan(); }); } } </code></pre> <p>I would like to query all orders, having a specific status and joining both <code>Release</code> and <code>Return</code> but for <code>Release</code>, I would like to also join in <code>Calendar</code> (which is a component-mapped entity) and for calendar I would like to join in all holidays (left outer join). I have tried a few different ways, but as soon as I try to join in holidays, I get a cartesian product (I assume I get both sites holidays).</p> <p>I also did an attempt with futures (like this):</p> <pre><code>var orders = Session.QueryOver&lt;Order&gt;() .Where(x =&gt; x.Status == Selected.Status) .Future&lt;Order&gt;(); Session.QueryOver&lt;Order&gt;() .JoinAlias(x =&gt; x.Release, () =&gt; release, JoinType.LeftOuterJoin) .JoinAlias(() =&gt; release.Calendar.Holidays, () =&gt; holiday, JoinType.LeftOuterJoin) .Where(x =&gt; x.Status == Selected.Status) .Future&lt;Order&gt;(); var output = orders.ToList(); </code></pre> <p>...but I still get more holidays than I expect. If I can get a query figured out, I would also like to filter holidays where <code>Date</code> > todays date.</p> <p>Is it at all possible to perform this query or is there an option I have missed?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload