Skip to content

Minimal API TimeZoneInfo for Serialization #1487

@andy-clymer

Description

@andy-clymer

I know you can set TimeZoneInfo on the ODataQuerySettings, but this appears to only be used in the ExpressionBinderHelper class and not for serialization.

It'd be nice to add the option to configure TimeZoneInfo for serialization like we have when using OData with controllers. Currently the result from an endpoint always comes back with DateTime displayed using the local time of the server.

Controller Service Configuration:

builder.Services.AddControllers()
    .AddOData(opt =>
    {
        opt.EnableQueryFeatures();
        opt.AddRouteComponents("odata", EdmModelHelper.GetEdmModel());
        opt.TimeZone = TimeZoneInfo.Utc; // Missing from Minimal API Service Configuration
    });

Minimal API Service Configuration Example:

builder.Services.AddOData(q =>
{
    q.EnableAll();
    q.SetCaseInsensitive(true);
    q.SetTimeZoneInfo(TimeZoneInfo.Utc); // Add something like this to be able to set DateTime serialization options.
});

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions