title: NHibernate support the function: LEN
body: <p>I want to get the results:</p>
  
  <pre><code>select * from Cate where LEN(code)=2
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>var filter1 = Restrictions.Eq(
                   Projections.SqlFunction("LEN", NHibernateUtil.Int32,
                                           Projections.Property("code")), 2);
               var query =
                   repository.Session.QueryOver&lt;Cate&gt;().Where(filter1).List();
               Assert.IsTrue(query.Count &gt; 0);
  </code></pre>
  
  <p>However, there have been errors:</p>
  
  <blockquote>
    <p>NHibernate.HibernateException : Current dialect
    NHibernate.Dialect.MsSql2008Dialect doesn't support the function: LEN</p>
  </blockquote>
  
  <p>How can I use in Nhibernate the SQLServer2008 of the Len function?</p>