title: NHibernate Criteria Where any element of list property is true
body: <p>I have an already created NHibernate <code>Criteria</code> query that I need to modified so I can add a new condition.</p>
  
  <p>The query is based on the <code>Order</code> object, which has a list of <code>OrderItems</code> and then, every <code>OrderItem</code> has a <em>bool</em> property named <code>FinalDeliveryIndicator</code>.</p>
  
  <p>In my Criteria query I need to add a condition in which I want all orders that at least one of its <code>OrderItems</code> has the <code>FinalDeliveryIndicator</code> bool set to <strong>true</strong>.</p>
  
  <p>The query, at the moment, is:</p>
  
  <pre><code>var search = NHibernateSession.CreateCriteria(typeof(Order))
              .CreateAlias("Contract", "C", JoinType.InnerJoin)
              .CreateAlias("C.Supplier", "S", JoinType.InnerJoin)
              .Add(Restrictions.Eq("Buyer.Id", companyId))
              .Add(Restrictions.Eq("IsDeleted", false))
              .Add(Restrictions.Eq("IsActiveVersion", true))
              .SetFirstResult(paging.PageIndexSQL)
              .SetMaxResults(paging.PageSize)
              .AddOrder(SortOrder.Desc("Id"));
  </code></pre>
  
  <p>Now I need to add that condition I told you about. This query is already in use at many places on this application and so I cannot switch to <em>QueryOver</em> or some other type of query, due to the risk of crashing something.</p>