If you use ReliableSqlConnection.ExecuteCommand<T> with a select which :
- returns a null value
int? as type parameter
The method will always fails with an InvalidCastException.
What is wrong is that ExecuteCommand calls ExecuteScalar, but suppose the result is "null" if the SQL wass NULL, but it's DBNull.Value which is returned instead.
if (result != null)
, line 327 should be replaced with, at least,
if (result != null && result != DBNull.Value)
to handle real null results.