Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time zone settings not propagated to query #384

Open
MrKevHunter opened this issue Nov 18, 2021 · 10 comments · May be fixed by #1033
Open

Time zone settings not propagated to query #384

MrKevHunter opened this issue Nov 18, 2021 · 10 comments · May be fixed by #1033
Assignees
Labels
bug Something isn't working Fixed

Comments

@MrKevHunter
Copy link

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 #268 But this doesn't seem to have fixed the issue in 8.0.4

@xuzhg
Copy link
Member

xuzhg commented Nov 30, 2021

See commit at: bcdf32e

@xuzhg xuzhg added the Fixed label Nov 30, 2021
@xuzhg
Copy link
Member

xuzhg commented Nov 30, 2021

@MrKevHunter would you please help verify your project using the latest nightly bit?

@MrKevHunter
Copy link
Author

@MrKevHunter would you please help verify your project using the latest nightly bit?

yep should be able to, will take a look

@MrKevHunter
Copy link
Author

MrKevHunter commented Dec 1, 2021

looks good to me, setting the timezone to UTC in the startup.cs fixes our issue

@manikandantk88
Copy link

manikandantk88 commented Dec 1, 2022

Could you please post the fix? I am facing the same issue

I am trying the latest 8.0.11 package.

@jineshpatel99
Copy link

Having the same issue with 8.0.12, Anyone found any fix? @MrKevHunter

@Olivercomputing
Copy link

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?

@darkeagle76
Copy link

I'm also see the problem.
Please check the description I provided in the issue #378.
Any suggestion?
Thanks
D

@pgrimmert
Copy link

pgrimmert commented Sep 6, 2023

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

@darkeagle76
Copy link

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed
Projects
None yet
8 participants