AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

getting-related-entities convention conflicted with ODataConventionModelBuilder.EnableLowerCamelCase()

Open sep2 opened this issue 2 years ago • 6 comments

Assemblies affected ASP.NET Core OData 8.0.8

Describe the bug

when ODataConventionModelBuilder.EnableLowerCamelCase() is enabled, the controller method described here will not be hit if the method name is GetSupplier. However it will be hit if the method is Getsupplier (lowercase s).

Expected behavior GetSupplier should work regardless the status of EnableLowerCamelCase().

sep2 avatar Apr 13 '22 04:04 sep2

You can enable a lot of routing options, for routing does that help?

builder.Services.AddControllers()
    .AddOData((options, serviceProvider) =>
    {
        options.RouteOptions.EnableKeyInParenthesis = true;
        options.RouteOptions.EnableNonParenthesisForEmptyParameterFunction = true;
        options.RouteOptions.EnableQualifiedOperationCall = true;
        options.RouteOptions.EnableUnqualifiedOperationCall = true;
        options.RouteOptions.EnablePropertyNameCaseInsensitive = true;
        options.RouteOptions.EnableControllerNameCaseInsensitive = true;

        options
            .Count().Filter().Expand().Select().OrderBy().SetMaxTop(1000);
    })

Gigabyte0x1337 avatar Apr 15 '22 11:04 Gigabyte0x1337

I can confirm that options.RouteOptions.EnableControllerNameCaseInsensitive = true did not help the issue.

sep2 avatar Apr 15 '22 11:04 sep2

@sep2 this should be fixed in 8.0.9. Can you update, test again and close this if it is fixed for you?

julealgon avatar Apr 18 '22 12:04 julealgon

@sep2 this should be fixed in 8.0.9. Can you update, test again and close this if it is fixed for you?

I tried 8.0.9 and the result is same, Getsupplier can work while GetSupplier cannot.

sep2 avatar Apr 19 '22 04:04 sep2

@sep2 Can you share with me your startup.cs and the whole controller?

Are you using conventional routing or attribute routing?

xuzhg avatar Apr 19 '22 16:04 xuzhg

@xuzhg Please see the repro here. https://github.com/sep2/odata-test-lowercase

Notice https://github.com/sep2/odata-test-lowercase/blob/main/ODataTest/EventsController.cs#L22 this can work because it is in lower case.

If I change that line to GetActivities, it won't work then.

sep2 avatar Apr 21 '22 09:04 sep2