In the documentation it is stated that EnableCaseInsensitive, EnableUnqualifiedNameCall and EnableEnumPrefixFree can be used to modify the OData behaviour on case, unqualified nam and enums without prefixes. But I can't find these in 7.0.0 beta 2 (Well I can actually find EnableCaseInsensitive, but not how to activate it)? Is this supposed to be like this, or have I missed something obvious and simple?
I also met the issue today, after finished a function and would like to use EnableUnqualifiedNameCall, but couldn't find it. Does anyone know these methods in which namespace with version 7.0.0 beta2?
For enable unqualified name call, register custom resolver Microsoft.OData.UriParser.UnqualifiedODataUriResolver
C#
builder.MapODataServiceRoute(routeName, prefix, containerBuilder =>
containerBuilder.AddService(ServiceLifetime.Singleton, sp => model)
.AddService(ServiceLifetime.Singleton, sp =>DefaultRouteConventions(routeName, builder))
.AddService<ODataUriResolver>(ServiceLifetime.Singleton, sp => new UnqualifiedODataUriResolver { EnableCaseInsensitive =true })
);
For enable enum prefix free, use resolver Microsoft.OData.UriParser.StringAsEnumResolver.
If you need combine two options, Microsoft.AspNetCore.OData contains class UnqualifiedCallAndEnumPrefixFreeResolver. I don't understood why this class internal.
@genusP Thanks, I'll take a look i this solves my issues!
Tested now and it seems to work, the documentation should reflect this since this is a change from previous implementation.
The class UnqualifiedCallAndEnumPrefixFreeResolver should definitely be public, for now I copied it into my own project.
@xuzhg, please make class UnqualifiedCallAndEnumPrefixFreeResolver as public
PR #1324 merged
Thanks!
@genusP How to let the OData Client Generator know the right namespace when using your code? Now it set's the Default.{action}.
@1Jesper1 Sorry, I don't use this library and can`t help you.
Most helpful comment
For enable unqualified name call, register custom resolver Microsoft.OData.UriParser.UnqualifiedODataUriResolver
C# builder.MapODataServiceRoute(routeName, prefix, containerBuilder => containerBuilder.AddService(ServiceLifetime.Singleton, sp => model) .AddService(ServiceLifetime.Singleton, sp =>DefaultRouteConventions(routeName, builder)) .AddService<ODataUriResolver>(ServiceLifetime.Singleton, sp => new UnqualifiedODataUriResolver { EnableCaseInsensitive =true }) );For enable enum prefix free, use resolver Microsoft.OData.UriParser.StringAsEnumResolver.
If you need combine two options, Microsoft.AspNetCore.OData contains class UnqualifiedCallAndEnumPrefixFreeResolver. I don't understood why this class internal.