title: NHibernate disjunction resulting in AND queries instead of OR
body: <p>This may be something obvious but I've been banging my head against it for a few hours and can't figure out where I'm going wrong.</p>
  
  <p>I'm trying to run a small piece of code to test adding OR criteria to an NHibernate query. This is the code I have:</p>
  
  <pre><code>using (ISession session = NHibernateHelper.OpenSession())
  {
      ICriteria criteria = session.CreateCriteria&lt;TestObject&gt;();
  
      int[] ids = {1, 2, 3};
      foreach (int id in ids)
      {
          ICriterion criterion = Restrictions.Eq("Id", id);
          criteria.Add(Restrictions.Disjunction().Add(criterion));
      }
  
      IList&lt;TestObject&gt; items = criteria.List&lt;TestObject&gt;();
      return items;
  }
  </code></pre>
  
  <p>It's just something simple that I would expect to return all test objects with IDs 1-3. But, when I'm running the code, the query generated is to find an object with ID = 1 AND ID = 2 AND ID = 3. Which, unsurprisingly, doesn't return anything.</p>
  
  <p>The mapping's set up correctly (I can add/edit/remove/list all of the objects) and there are objects in there with these IDs.</p>
  
  <p>Am I doing something obviously wrong? Any samples of using Disjunction I've seen online all seem to use it this way. I just don't get why it keeps on using AND.</p>
  
  <p>Thanks.</p>