title: Get Row Count InvalidCast Exception from ScalarQuery
body: <pre><code>ScalarQuery&lt;int&gt; query = new ScalarQuery&lt;int&gt;(typeof(Role), 
                           "select count(role.RoleId) from Role as role");
  return query.Execute();
  </code></pre>
  
  <p>It fails with the invalidcast exception but succeeds when count is replaced with max. </p>