title: Querying with NHibernate
body: <p>I am new to NHibernate and I am trying to learn how to query my data.</p>
  
  <p>Below is the configuration xml. Only the recipe is shown.</p>
  
  <p>I want to be able to query recipes by recipetitle from keywords entered
  and also ingredients from ingredientname.</p>
  
  <p>So you might enter "pasta wine" for example.</p>
  
  <p>This is what I have tried but gives me an error.</p>
  
  <pre><code>    hql = "from Recipe r " +
      "left join r.Images " +
      "inner join r.User " +
      "inner join r.Ingredients i " +
      "where i.IngredientName Like '%pasta%' OR i.IngredientName Like '%wine%' OR r.RecipeTitle Like '%pasta' OR r.RecipeTitle Like '%wine%'";
  </code></pre>
  
  <p>I want to eager load the collections as well.</p>
  
  <p>Am I going about querying right??
  I need to able to build the query string from my search criteria.
  This would be easy form me in SQL.</p>
  
  <p>Malcolm</p>
  
  <pre><code>  &lt;class name="Recipe" table="Recipes" xmlns="urn:nhibernate-mapping-2.2"&gt;
      &lt;id name="RecipeID" type="Int32" column="RecipeID"&gt;
        &lt;generator class="identity" /&gt;
      &lt;/id&gt;
      &lt;property name="RecipeTitle" type="String"&gt;
        &lt;column name="RecipeTitle" /&gt;
      &lt;/property&gt;
      &lt;property name="Completed" type="Boolean"&gt;
        &lt;column name="Completed" /&gt;
      &lt;/property&gt;
      &lt;property name="ModifiedOn" type="DateTime"&gt;
        &lt;column name="ModifiedOn" /&gt;
      &lt;/property&gt;
      &lt;property name="Rating" type="Double"&gt;
        &lt;column name="Rating" /&gt;
      &lt;/property&gt;
      &lt;property name="PrepTime" type="Int32"&gt;
        &lt;column name="PrepTime" /&gt;
      &lt;/property&gt;
      &lt;property name="CookTime" type="Int32"&gt;
        &lt;column name="CookTime" /&gt;
      &lt;/property&gt;
      &lt;property name="Method" type="String"&gt;
        &lt;column name="Method" /&gt;
      &lt;/property&gt;
      &lt;bag name="Images" inverse="true" cascade="all"&gt;
        &lt;key column="RecipeID" /&gt;
        &lt;one-to-many class="OurRecipes.Domain.RecipeImage, OurRecipes.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
      &lt;/bag&gt;
      &lt;many-to-one name="Category" column="CategoryID" /&gt;
      &lt;bag name="Comments" inverse="true" cascade="all"&gt;
        &lt;key column="RecipeID" /&gt;
        &lt;one-to-many class="OurRecipes.Domain.Comment, OurRecipes.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
      &lt;/bag&gt;
      &lt;many-to-one name="User" column="EnteredByID" /&gt;
      &lt;bag name="Ingredients" inverse="true" cascade="all"&gt;
        &lt;key column="RecipeID" /&gt;
        &lt;one-to-many class="OurRecipes.Domain.Ingredient, OurRecipes.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
      &lt;/bag&gt;
    &lt;/class&gt;
  </code></pre>