title: NHibernate Criteria question
body: <p>I have a person object, which can have unlimited number of first names.  So the first names are another object.</p>
  
  <p>ie</p>
  
  <p>person --- name<BR />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      --- name<BR />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;       --- name<BR /></p>
  
  <p>What I want to do is write an nhiberate query using which will get me a person who has certain names.</p>
  
  <p>so one query might be find someone whose names are alison and jane and philippa, then next query may be one to find someone whose names are alison and jane.</p>
  
  <p>I only want to return people who have all the names I'm search on.  So far I've got</p>
  
  <pre><code>ICriteria criteria = session.CreateCriteria(typeof (Person));
  criteria.CreateAlias("Names", "name");
  ICriterion expression = null;
  foreach (string name in namesToFind)
  {
      if (expression == null)
      {
          expression = Expression.Like("name.Value", "%" + name + "%");
      }
      else
      {
          expression = Expression.Or(
              expression,
              Expression.Like("name.Value", "%" + name + "%"));
      }
  }
  
  if (expression != null)
      criteria.Add(expression);
  </code></pre>
  
  <p>But this is returning every person with ANY of the names I'm searching on, not ALL the names.</p>
  
  <p>Can anyone help me out with this?  Thanks!</p>