title: Getting a boolean from a SELECT in SQL Server into a bool in C#?
body: <p>I have this code in my SELECT:</p>
  
  <pre><code>SELECT  A.CompletedDate,
      CASE
          WHEN (@AdminTestId IS NULL AND @UserTestId IS NULL) THEN 0
          WHEN (@AdminTestId = temp.AdminTestId AND @UserTestId = A.UserTestId) THEN 1
          WHEN (@AdminTestId = temp.AdminTestId AND @UserTestId IS NULL) THEN 1
      ELSE 0
      END AS [Current], 
  </code></pre>
  
  <p>and in my ASP.NET DTO I have:</p>
  
  <pre><code>public partial class GetTestsDTO
  {
      public bool? GradePass { get; set; }
      // the following line is what is giving the error. If I remove
      // the line it will not try to convert the data and there is no
      // error. Note that I want to put this into a bool as web.api
      // then passes it to the client as a bool
      public bool Current { get; set; } 
      public DateTime? CompletedDate { get; set; }
  }
  </code></pre>
  
  <p>It's giving me an error and I would appreciate some help. </p>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>message=The specified cast from a materialized 'System.Int32' type to
    the 'System.Boolean' type is not valid.</p>
  </blockquote>