Skip to content

Conversation

@0xced
Copy link
Contributor

@0xced 0xced commented May 1, 2025

It would probably a good idea to merge MarkPflug/Sylvan.Data.Excel#198 first, though.

@0xced 0xced force-pushed the Date-to-DateOnly branch from cb1ff94 to 09a90be Compare May 2, 2025 09:24
@MarkPflug
Copy link
Owner

@0xced, I'm reluctant to merge this. I'd like to maintain consistent behavior between frameworks, and this would potentially cause a break if someone moved from an older framework to a new one that supports these new types. I agree with what you're trying to achieve though, as DateOnly feels like the more appropriate type for this scenario. I'm wondering if there is a way to accomplish this via the data binder instead, allowing DateTime values to be bound to DateOnly properties, maybe requiring that the time component is zero.

@0xced
Copy link
Contributor Author

0xced commented May 2, 2025

I just pushed ab72769 which introduces a new AppContext switch to restore the previous behaviour of mapping DbType.Date to DateTime (instead of DateOnly).

AppContext.SetSwitch("Sylvan.Data.MapDateToDateTime", true);

This allows to move forward with the new DateOnly type while also providing an escape hatch if needed.

@0xced
Copy link
Contributor Author

0xced commented May 22, 2025

EF Core 8 went with a breaking change regarding this topic too.

SQL Server date and time now scaffold to .NET DateOnly and TimeOnly

0xced added 2 commits May 27, 2025 18:01
…Time

The behaviour of mapping mapping DbType.Date to DateTime (instead of DateOnly) can be restored by setting the new `Sylvan.Data.MapDateToDateTime` AppContext switch.

```csharp
AppContext.SetSwitch("Sylvan.Data.MapDateToDateTime", true);
```
@0xced 0xced force-pushed the Date-to-DateOnly branch from ab72769 to e7cbd4d Compare May 27, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants