title: casting string to bool using nHibernate Criteria
body: <p>I have an nHibernate query using Criteria, and I am trying to cast a string to bool in the query itself. I have done the same with casting a string to int, and that works well (the "DataField" property is "1" as a string):</p>
  
  <pre><code>var result = Session
     .CreateCriteria&lt;Car&gt;()
     .Add(Restrictions.Eq((Projections.Cast(NHibernateUtil.Int32,
      Projections.Property("DataField"), 1))
     .List&lt;Car&gt;();
  
  tx.Commit();
  </code></pre>
  
  <p>But I am trying to do the same with bool, but I do not get the expected result:</p>
  
  <pre><code>var result = Session
     .CreateCriteria&lt;Car&gt;()
     .Add(Restrictions.Eq((Projections.Cast(NHibernateUtil.bool,
      Projections.Property("DataField"), true))
     .List&lt;Car&gt;();
  
  tx.Commit();
  </code></pre>
  
  <p>"DataField" is the string "True", but the result in an empty list, where it should contain 100 elements with the "DataField" property string set to "True". I have tried with the string "true", and "1", but the result is still an empty List.</p>
  
  <p>[EDIT]</p>
  
  <p>As Commented below, I could check for the string "True" or "False", but I would say this is a more general question than just for the Boolean.</p>
  
  <p>Note that the idea is to have some sort of key value representation of the data, where the value can be different data types. I need the value table to contain all data, so storing the data as string seems like the cleanest solution!</p>
  
  <p>I have been able to use the method above to store both int and double as string, and to the cast in the query, but I have not succeeded using the same method for DateDime and Boolean.</p>
  
  <p>And for DateTime it is crucial to have the actual DateTime object. </p>
  
  <p>How can I make the cast from string to bool, and string to DateTime work in the queries?</p>
  
  <p>Thanks</p>