Skip to content

How to deal with DBNull but want to go into a normal field #164

@Smurf-IV

Description

@Smurf-IV

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 mins
                    commandType: CommandType.StoredProcedure);
            return result.ToArray();  // <- Boom with AOT!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions