title: boolean value in case statement in sql query
body: <p>I am using case statement in select query some thing like this.</p>
  
  <pre><code>Select col1, col2, isActive = case when col3 = 'abc' then 1  else  0 end, col4
  from &lt;tablename&gt; where &lt;some condition&gt;.
  </code></pre>
  
  <p>when i read the 'isActive' column value in ado.net - </p>
  
  <pre><code>bool isActiveFlag = (bool)datareader["isActive"];
  </code></pre>
  
  <p>I get type cast error. because it is returning value as int. </p>
  
  <p>If i change query to </p>
  
  <pre><code>Select col1, col2, isActive = case when col3 = 'abc' then 'true' else 'false' end, col4
  from &lt;tablename&gt; where &lt;some condition&gt;.
  </code></pre>
  
  <p>I get same type cast error because this time returned value is string. Basically i want query to assign boolean value to 'isActive' in query, so that i can read it as boolean value.</p>
  
  <pre><code>bool isActiveFlag = (bool)datareader["isActive"];
  </code></pre>
  
  <p>Any idea how to deal with this ?</p>
  
  <p>I don't want to read the value as int or string and then convert the value to boolean.</p>