DapperLib / DapperLib/DapperAOT

Interceptor System.InvalidCastException: Invalid cast from 'System.DateTime' to 'System.DateTimeOffset'

Open
#141 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
472
Forks
43
Avg merge
1d 4h
Merged PRs (30d)
18

Description

System.InvalidCastException: Invalid cast from 'System.DateTime' to 'System.DateTimeOffset'.

at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)

at Dapper.RowFactory.GetValue[T](DbDataReader reader, Int32 fieldOffset) in /_/src/Dapper.AOT/RowFactory.cs:line 63

at Dapper.AOT.<Aec_Ppt_Service_DataAccess_generated>F9DBDBCB1F13C94DA6E339DF48F1A98215026BBECA8DE5F265C5ACAD26E3BC904__DapperGeneratedInterceptors.RowFactory1.Read(DbDataReader reader, ReadOnlySpan`1 tokens, Int32 columnOffset, Object state) in D:\source\Aec.Ppt.Service\Aec.Ppt.Service.DataAccess\obj\Debug\net8.0\Dapper.AOT.Analyzers\Dapper.CodeAnalysis.DapperInterceptorGenerator\Aec.Ppt.Service.DataAccess.generated.cs:line 369
A clear and concise description of what the bug is.

Where are you seeing this?

  • Dapper.AOT latest version?

Expected behavior
Code works without errors

Screenshots
N/A

Additional context

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/Dapper.AOT/RowFactory.cs line 63 and compare it with the generated interceptor location reported at line 369. Reproduce the DateTime-to-DateTimeOffset mapping failure with the reported data reader scenario, then determine the expected conversion behavior. Done means the reported mapping no longer throws and the behavior is covered by an appropriate regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.