title: Query Parameter Value Is Null When Enum Item 0 is Cast with Int32
body: <p>When I use the first item in a zero-based Enum cast to Int32 as a query parameter, the parameter value is null. I've worked around it by simply setting the first item to a value of 1, but I was wondering though what's really going on here? This one has me scratching my head. Why is the parameter value regarded as null, instead of 0?</p>
  
  <pre><code>Enum LogEventType : int
  {
      SignIn,
      SignInFailure,
      SignOut,
      ...
  }
  
  private static DataTable QueryEventLogSession(DateTime start, DateTime stop)
  {
      DataTable entries = new DataTable();
  
      using (FbConnection conn = new FbConnection(DSN))
      {
          using (FbDataAdapter adapter = new FbDataAdapter(
              "SELECT event_type, event_timestamp, event_details FROM event_log " +
              "WHERE event_timestamp BETWEEN @start AND @stop " +
              "AND event_type IN (@signIn, @signInFailure, @signOut) " +
              "ORDER BY event_timestamp ASC", conn))
          {
              adapter.SelectCommand.Parameters.AddRange(new Object[] {
                  new FbParameter("@start", start),
                  new FbParameter("@stop", stop),
                  new FbParameter("@signIn", (Int32)LogEventType.SignIn),
                  new FbParameter("@signInFailure", (Int32)LogEventType.SignInFailure),
                  new FbParameter("@signOut", (Int32)LogEventType.SignOut)});
  
              Trace.WriteLine(adapter.SelectCommand.CommandText);
              foreach (FbParameter p in adapter.SelectCommand.Parameters)
              {
                  Trace.WriteLine(p.Value.ToString());
              }
  
              adapter.Fill(entries);
          }
      }
      return entries;
  }
  </code></pre>