title: nhiberate Subquery with criteria
body: <p>how am i able to join/add SubQuery to a criteria ? what I wanted to do is able to make a SubQuery that will search String Product which is getCustomerProduct (two table joins). and I also want it able to do a soundex search. 
  my problem is, I am not sure if my subquery is right or not unless i run it, how can i add it to the criteria ?  I am new to nhiberate, thanks for help !</p>
  
  <pre><code>   public IPagedList&lt;Customer&gt; GetSearchPagedCustomer(string product, string address, string county, int pagenumber, int pageSize)
       {
      ICriteria criteria = Session.CreateCriteria&lt;Customer&gt;();
  
                  //.CreateAlias("Products", "cp")
                  //.CreateAlias("cp.Product", "p");
  
                  if (!string.IsNullOrEmpty(product))
                  {
                      var getCustomerProduct = DetachedCriteria.For&lt;Product&gt;()
                          .SetProjection(Projections.Distinct(Projections.Property("Products.id")))
                          .CreateCriteria("Product", JoinType.InnerJoin)
                          .Add(Restrictions.Eq("Product.Name",product));
  
                      //criteria.Add(Restrictions.Like("Name", product));
                  }            
                  if (!string.IsNullOrEmpty(address))
                  {
                      criteria.Add(Restrictions.Like("Address1", address, MatchMode.Anywhere) || Restrictions.Like("Address2", address, MatchMode.Anywhere) || Restrictions.Like("Address3", address, MatchMode.Anywhere));
                  }
                  if (!string.IsNullOrEmpty(county))
                  {
                      criteria.Add(Restrictions.Like("County", county, MatchMode.Anywhere));
                  }
  
  return criteria.Future&lt;Customer&gt;().ToPagedList&lt;Customer&gt;(pageNumber, pageSize);
  }
  </code></pre>