feat: DateOnly
and TimeOnly
support
#129
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In .NET6 DateOnly and TimeOnly were introduced. Current PR proposes support for those in Dapper.AOT.
I performed testing against MsSql and PostgreSql. Check DateOnlyTimeOnlyTests.cs for validating how data is being parsed from database via
System.Data.Common.DbDataReader
.Here is how data is parsed and how I convert it:
DateTime
DateTime
Convert.ToDateTime()
DateTime
DateTime
Convert.ToDateTime()
DateOnly
DateTime
Convert.ToDateTime()
->DateOnly.FromDateTime()
TimeOnly
DateTime
Convert.ToDateTime()
->TimeOnly.FromDateTime()
DateTime
DateTime
Convert.ToDateTime()
DateOnly
DateTime
Convert.ToDateTime()
->DateOnly.FromDateTime()
TimeOnly
DateTime
Convert.ToDateTime()
->TimeOnly.FromDateTime()
default(TimeOnly)
. Dont know if it is better to explicitly throw here?DateTime
TimeSpan
Convert.ToDateTime()
throwsInvalidCastException
DateOnly
TimeSpan
Convert.ToDateTime()
throwsInvalidCastException
TimeOnly
TimeSpan
object
arg toTimeSpan
->TimeOnly.FromTimeSpan()
I have adjusted the implementation of
CommandUtils.As<T>
according to the table above, and then wrote integration tests (only for postgreSql).Note: I also wrote a code to exclude non-compatible input files for unit Interceptors tests (we dont need to run .netFx tests against
DateOnly.input.cs
, because .netFx does not supportDateOnly
andTimeOnly
types).Closes #116