title: LIKE query for DateTime in NHibernate
body: <p>For a column of type varchar I could write such search query:</p>
  
  <pre><code>public IList&lt;Order&gt; GetByName(string orderName)
  {
   using (ISession session = NHibernateHelper.OpenSession())
   {
    return session.CreateCriteria&lt;Order&gt;().
     Add(Restrictions.Like("Name", string.Format("%{0}%", orderName))).
     List&lt;Order&gt;();
   }
  }
  </code></pre>
  
  <p>How do I implement the similar search query for a column that has a DateTime type?</p>
  
  <pre><code>public IList&lt;Order&gt; GetByDateTime(string str)
  {
      using (ISession session = NHibernateHelper.OpenSession())
      {
          return session.CreateCriteria&lt;Order&gt;()
              .Add(Restrictions.Like(Projections.Cast(NHibernateUtil.String, Projections.Property("Created")),
                                      '%' + str + '%'))
              .List&lt;Order&gt;();
      }
  }
  </code></pre>
  
  <p>That is, if the method is passed the date and part-time (eg "25.03.2010 19"), then displays all orders are carried out in this period of time:
  <br>25.03.2010 19:22:00
  <br>25.03.2010 19:44:00
  <br>25.03.2010 19:59:00</p>