title: Using SQL CONVERT function through nHibernate Criterion
body: <p>I have a sql view, in which the data type of every column is <code>string</code>, for use with the jquery datatables plugin. </p>
  
  <p>One of the columns contains a uk format date dd/mm/yyyy. </p>
  
  <p>This column needs to remain a string to work with the keystroke filtering of the plugin, however for sorting it needs to be treated as a date. </p>
  
  <p>I am using nhibernate criteria to create the sql query and I want to generate the following order by clause, as this orders the dates correctly</p>
  
  <pre><code>order by CONVERT (datetime, DateOfBirth, 103)
  </code></pre>
  
  <p>However in <code>Nhibernate.Criterion.Projections</code> there is no <code>Convert</code> method. There is <code>Cast</code>, but I get the following error due to the fact that it is a UK date format:</p>
  
  <pre><code>The conversion of a varchar data type to a datetime data type 
  resulted in an out-of-range value
  </code></pre>
  
  <p>I have tried also tried the following:</p>
  
  <pre><code> criteria.AddOrder(
               Order.Desc(
       Projections.SqlFunction(
                                "CONVERT",
                                 NHibernateUtil.DateTime, 
                                 new IProjection[]
                                 {
                                   Projections.Property(propNames[orderByColumn]), 
                                   Projections.Property("104")
                                 }
                               )
                           )
                     ); 
  </code></pre>
  
  <p>But I get the following error message:</p>
  
  <pre><code>NHibernate.HibernateException: Current dialect 
         NHibernate.Dialect.MsSql2008Dialect doesn't support the function: CONVERT
  </code></pre>
  
  <p>Can the SQL convert function be used when using <code>Nhibernate.Criterion</code> ?</p>