When reading a nullable int column with GetFieldValueAsync<int?>, an InvalidCastException is thrown for DBNull values. The synchronous GetFieldValue<int?> works correctly on the same column.
What happens
using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
var value = await reader.GetFieldValueAsync<int?>(0); // throws on DBNull rows
}
Expected: returns null for DBNull rows, same as the sync path.
Actual: InvalidCastException: Specified cast is not valid.
This is blocking us from migrating an async pipeline.
When reading a nullable
intcolumn withGetFieldValueAsync<int?>, anInvalidCastExceptionis thrown forDBNullvalues. The synchronousGetFieldValue<int?>works correctly on the same column.What happens
Expected: returns
nullforDBNullrows, same as the sync path.Actual:
InvalidCastException: Specified cast is not valid.This is blocking us from migrating an async pipeline.