You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to deal with DBNull but want to go into a normal field #164
So the conversion works ok with Dapper reflection, but with AOT it throws at this point result.PrimaryIncome = GetValue<double>(reader, columnOffset);
I think the value might be null, but the field type is not "Nullable" (Legacy code, and is also serialised elsewhere, so defo cannot change!)
Is there some attribute that can be applied to state that DBNulls are converted to zero's (Or even Nan for doubles?)
Code:
IEnumerable<MLModelInput>result=connection.Query<MLModelInput>(sProcName,new{PoolCutOffDate=poolCutOffDate},buffered:false,commandTimeout:1800,// Set timeout to 30 minscommandType:CommandType.StoredProcedure);returnresult.ToArray();// <- Boom with AOT!!
Not sure this is relevant, but I tried this when the exception was thrown:
reader.GetDouble(columnOffset)
'reader.GetDouble(columnOffset)' threw an exception of type 'System.InvalidOperationException'
Data:{System.Collections.ListDictionaryInternal}HResult:-2146233079HelpLink:nullInnerException:nullMessage:"Invalid attempt to read from column ordinal '22'. With CommandBehavior.SequentialAccess, you may only read from column ordinal '199' or greater."Source:"Microsoft.Data.SqlClient"StackTrace:" at Microsoft.Data.SqlClient.SqlDataReader.CheckDataIsReady(Int32 columnIndex, Boolean allowPartiallyReadColumn, Boolean permitAsync, String methodName)\r\n at Microsoft.Data.SqlClient.SqlDataReader.TryReadColumn(Int32 i, Boolean setTimeout, Boolean allowPartiallyReadColumn, Boolean forStreaming)\r\n at Microsoft.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean setTimeout, Boolean allowPartiallyReadColumn)\r\n at Microsoft.Data.SqlClient.SqlDataReader.GetDouble(Int32 i)\r\n at <>x.<>m0(RowFactory0 <>4__this, DbDataReader reader, ReadOnlySpan`1 tokens, Int32 columnOffset, Object state)"
TargetSite:{Void CheckDataIsReady(Int32,Boolean,Boolean,System.String)}
Activity
Smurf-IV commentedon Jul 28, 2025
The "Code" that used to be used before using dapper was this:
Being able to do something similar with AOT via an attributes or
QueryAPI call setting would be idealSmurf-IV commentedon Jul 28, 2025
Not sure this is relevant, but I tried this when the exception was thrown: