DateOnlyTimeOnly.AspNet
DateOnlyTimeOnly.AspNet copied to clipboard
It's impossible to use DateOnly in the Dictionaries
The type 'System.DateOnly' is not a supported dictionary key using converter of type 'DateOnlyTimeOnly.AspNet.Converters.DateOnlyJsonConverter'.
[HttpGet]
[Route("date-foo")]
public async Task<Dictionary<DateOnly, Foo>> GetDatedFoos() {
{
return results.ToDictionary(x=> x.date, x=> x.foo);
}
I think, that's the limitation of System.Text.Json serializer: https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-supported-collection-types?pivots=dotnet-6-0#supported-key-types
But I'll take a look if I can do anything about it.
Had some time today. Turns out, .Net 7 (RC2) actually supports DateTime and DateOnly (but interestingly not TimeOnly) as Dictionary key.
Will work on adding it to this package.

thank you, Max
@veonua @ibiza240 You can try version 2.0.0-preview.1, it should be fixed there