title: Using NHibernate to retrieve a set of records with a single query and composite keys
body: <p>I am using Nhibernate and it's mapping-by-code flavour to retrieve a set of records using a list of composite keys. I am using composite keys like this:</p>
  
  <pre><code>public class PersonAccountKey : IKey
  {
          public virtual string PersonId { get; set; }
          public virtual string AccountNo{ get; set; }
  
          public override bool Equals(object obj)
          {
              if (obj == null)
                  return false;
              var t = obj as PersonKey;
              if (t == null)
                  return false;
              if (PersonId == t.PersonId &amp;&amp; AccountNo == t.AccountNo)
                  return true;
              return false;
          }
          public override int GetHashCode()
          {
              return (PersonId).GetHashCode() + "|" + (AccountNo).GetHashCode();
          }
  }
  </code></pre>
  
  <p>With a list of PersonAccountKey objects, I am trying to get NHibernate to send a single query down to database. I would imagine the query would look like this:</p>
  
  <pre><code>Select PersonId, AccountNo, AccountNickName 
  From PersonAccount 
  Where (PersonId = '11' and AccountNo = '10001111') 
  or (PersonId = '22' and AccountNo = '10001150')
  </code></pre>
  
  <p>I'm not sure how to achieve this? I tried to use Criteria with composite keys, but I don't think it was meant to be used together. I am trying now Linq 2 NHibernate but am not really getting anywhere either.</p>
  
  <p>Ideally, I would like a method that would take a IEnumerable of keys such as <code>Session.Get&lt;T&gt;(IEnumerable&lt;object&gt;)</code>, but this doesn't exist from my searching.</p>
  
  <p>Is this possible out of the box with NHibernate?</p>
  
  <p>Cheers.</p>