title: CreateCriteria over a collection of simple types
body: <p>How can I query using <code>CreateCriteria</code> over a collection of simple types?</p>
  
  <p>For example, I have 1 class</p>
  
  <pre><code>public class Test
  {
      public virtual Guid Id { get; set; }
  
      private ICollection&lt;int&gt; _values = new HashedSet&lt;int&gt;();        
      public virtual ICollection&lt;int&gt; Values
      {
          get { return _values; }
      }
  }
  </code></pre>
  
  <p>And 2 tables to support it:</p>
  
  <ul>
  <li>Test with only 1 column: Id</li>
  <li>Values with 2 columns: TestId and Value</li>
  </ul>
  
  <p><strong>My goal is to rewrite the following query using <code>CreateCriteria</code></strong>:</p>
  
  <pre><code>select * from test t
  inner join values v on v.TestId = t.Id
  where v.Value = 10
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>Session.CreateCriteria&lt;Test&gt;("test")
    .CreateAlias("test.Values", "values")
    .Add(Restrictions.Eq("values", 10))
    .List();
  </code></pre>
  
  <p>Like I would done it with a collection of objects and, obviously, failed. The join is correct but how to add a restriction?</p>