title: Castle ActiveRecord: 'System.Int32' cannot be converted to type 'System.Boolean'
body: <p>I'm having some problems with the SqlNamedQuery attribute that has been added to the newer version of Castle's ActiveRecord. I have specified it like this:</p>
  
  <pre><code>[assembly: SqlNamedQuery(Queries.GetItemName, "EXEC [dbo].[GetItemName] :id")]
  </code></pre>
  
  <p>Apart from that I have a property in the result mapping declared as:</p>
  
  <pre><code>...
  [Property(Access = PropertyAccess.AutomaticProperty, NotNull = true)]
  public virtual bool IsPrimaryName { get; set; }
  ...
  </code></pre>
  
  <p>Nhibernate query:</p>
  
  <pre><code>IQuery query = Session.GetNamedQuery(Queries.GetItemName);
  query.SetParameter("id", 1212, NHibernateUtil.Int64);
  query.SetResultTransformer(Transformers.AliasToBean&lt;Mapping&gt;());
  </code></pre>
  
  <p>After execution I receive the following exception:</p>
  
  <pre><code>Object of type 'System.Int32' cannot be converted to type 'System.Boolean'.
  </code></pre>
  
  <p>I have also added the below web.config entry but with no success (probably it only applies to hql queries).</p>
  
  <pre><code>&lt;add key="query.substitutions" value="true 1, false 0, yes 'Y', no 'N'" /&gt;
  </code></pre>
  
  <p>So, my question is - how can I resolve this problem? The stored procedure returns 0 or 1 but I've also tried with '1', 'true', 'TRUE' etc. How can I get around this? Or maybe I should just drop the SqlNamedQueries?</p>
  
  <p>UPDATE: Stack Trace</p>
  
  <pre><code>[ArgumentException: Object of type 'System.Int32' cannot be converted to type 'System.Boolean'.]
  System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast) +4070954
  System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr) +9631414
  System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig) +151
  System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +223
  System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +28
  System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) +101
  System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) +25
  NHibernate.Properties.BasicSetter.Set(Object target, Object value) +68
  </code></pre>
  
  <p>UPDATE: Select statement:</p>
  
  <pre><code>SELECT  
          itm.ItemId AS ItemId,
          itm.Value AS Value,
          itm.Id AS ParentId,
          1 AS IsPrimaryName
  FROM    
          [dbo].[Item] AS itm
  ...
  </code></pre>
  
  <p>As I've mentioned above I have tried several different scenarios on the sp side, including: '1', 'true', 'TRUE' + declaring a BIT variable and returning it directly from the select statement but it all fails with similar exception.</p>
  
  <p>Thx!</p>