DapperLib / DapperLib/DapperAOT
How to deal with DBNull but want to go into a normal field
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 472
- Forks
- 43
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 18
Description
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!!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the AOT failure at result.ToArray() and review the mapping call result.PrimaryIncome = GetValue(reader, columnOffset). Check how DBNull is handled when the target field is a non-nullable double. Done requires a documented or implemented resolution for the requested DBNull-to-zero or NaN behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100