43
While it's convenient to reference reader["StockValue"], it's not very efficient. It's also not strongly-typed, as it returns type object.
Instead, within your code, do something like this:
int stockValueOrdinal = reader.GetOrdinal("StockValue");
int? stockValue = reader.IsDbNull(stockValueOrdinal) ?
null :
reader.GetInt32(stockValueOrdinal);
Of course, it's best to get all of the ordinals at one time, then use them throughout the code.
int? stockValue = reader["StockValue"] == null || reader["StockValue"] == DBNull.Value ? null : (int?)reader["StockValue"];