title: Nhibernate QueryOver Field1 = True OR (Collection contains...)
body: <p>I'm writing a handler for a search form. The object being searched has 3 boolean flags and several collections (as <code>ISet</code>)</p>
  
  <p>These are related in that the flags represent abstract groupings of individual members of the collections. In this specific case, the collections represent Counties, Cities, and very broad "Regions." The boolean flags are for the author to specify that an entity IsOutOfState, IsStatewide, and/or IsEverywhere (e.g. Internet).</p>
  
  <p>There are additional non-geographic collections (e.g. Topics). Any restriction on this would be "and"ed with the geographic restrictions.</p>
  
  <p>On the search form, a user can check off particular geographic areas of interest (specific counties and/or cities and/or regions) as well as broadening their search to include items with one or more of the extra boolean flags set (if they don't check the box, we don't restrict the boolean fields).</p>
  
  <p>Writing this manually in SQL, I'd do something like:</p>
  
  <pre><code>SELECT ... FROM foo LEFT JOIN FooCounties fc ON foo.ID = fc.ID 
  LEFT JOIN FooCities fct ON foo.ID = fct.ID ...
  INNER JOIN FooTopics ft ON foo.ID = ft.ID
  WHERE (fc.CountyID IN (1, 2, ...) OR fct.CityID IN (1, 3, 5, ...) OR foo.IsStatewide = 1)
        AND ft.TopicID IN (1, 4, 7, ...)
  </code></pre>
  
  <p>How can I translate this to QueryOver? So far I've got the Topics and other AND criteria OK by something like this:</p>
  
  <pre><code>var query = Session.QueryOver&lt;foo&gt;();
  
  if (SelectedTopicIDs.Count &gt; 0) { 
    var TopicSubQ = QueryOver.Of&lt;foo&gt;().JoinQueryOver&lt;Topic&gt;(t =&gt; t.Topics)... etc.
    query = query.WithSubquery.WhereProperty(p =&gt; p.Id).In(TopicSubQ);
  }
  </code></pre>
  
  <p>But I can't figure out how I would use <code>Disjunction</code> to compare up to 3 bools and up to 3 subqueries, and then merge that all as an 'and' with the existing criteria.</p>