AspNetCoreOData
AspNetCoreOData copied to clipboard
Time zone settings not propagated to query
Using Microsoft.AspNetCore.OData V 8.0.4
in my startup I set
.AddOData(opt =>
{
opt.Select().Filter().OrderBy().Count().SetMaxTop(1000)
.AddRouteComponents("api", EdmModelBuilder.GetEdmModel())
.TimeZone = TimeZoneInfo.Utc;
opt.EnableAttributeRouting = true;
})
And specify the time zone i want to use
When using
[HttpGet("api/my-endpoint")]
[EnableQuery(PageSize = 44, MaxTop = 100, AllowedQueryOptions = AllowedQueryOptions.All)]
The ExpressionBinderHelper
is not setting the TimeZone
right = DateTimeOffsetToDateTime(right, querySettings.TimeZone, querySettings);
https://github.com/OData/AspNetCoreOData/blob/master/src/Microsoft.AspNetCore.OData/Query/Expressions/ExpressionBinderHelper.cs#L76
Has a null timezone
I've read https://github.com/OData/AspNetCoreOData/issues/268 But this doesn't seem to have fixed the issue in 8.0.4
See commit at: bcdf32e285072ae0552847b0518ae4036ebab91f
@MrKevHunter would you please help verify your project using the latest nightly bit?
@MrKevHunter would you please help verify your project using the latest nightly bit?
yep should be able to, will take a look
looks good to me, setting the timezone to UTC in the startup.cs fixes our issue
Could you please post the fix? I am facing the same issue
I am trying the latest 8.0.11 package.
Having the same issue with 8.0.12, Anyone found any fix? @MrKevHunter
I'm seeing the same problem with the latest version as of 6/29/2023. Breaking Datetime values is a huge problem, how is this still broken?
I'm also see the problem. Please check the description I provided in the issue #378. Any suggestion? Thanks D
We are also facing this issue, only enabling legacyTimestampBehavior on postgres does fix it for now. I have placed a module initializer in the repo project while also setting UTC in odatasettings:
ODataSettings = new ODataSettings
{
TimeZone = TimeZoneInfo.Utc,
},
public static class PostgresModuleInitializer
{
[ModuleInitializer]
public static void Initialize()
{
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
}
}
@darkeagle76
@pgrimmert My original problem is not related to postgres but thanks for the hint! I see you also saw my PR... I hope someone will approve it soon. Thanks!