Skip to content

OData client case insensitivity not working #3458

@mdsharpe

Description

@mdsharpe

Describe the bug

It does not appear to be possible to make the .NET OData client work with case-insensitive / lower-camel-case OData APIs.

When results are being materialized by the client library, properties fail to match due to case sensitive string comparison, even when ODataMessageReaderSettings.EnablePropertyNameCaseInsensitive is set to true, e.g. in the OnMessageReaderSettingsCreated event.

This means all received entities have default values for all properties.

Assemblies affected

Microsoft.OData.Client 8.x and 9.0.0-preview.3.

Steps to Reproduce

  • Configure OData API with ModelBuilder.ModelBuilderFactory returning a ODataConventionModelBuilder with EnableLowerCamelCaseForPropertiesAndEnums.
  • I also have RouteOptions EnableControllerNameCaseInsensitive, EnableActionNameCaseInsensitive, and EnablePropertyNameCaseInsensitive set to true, though I don't think this matters.
  • Configure OData Client as follows:
Configurations.ResponsePipeline.OnMessageReaderSettingsCreated(settings =>
{
    settings.Settings.EnablePropertyNameCaseInsensitive = true;
});

Expected behaviour

I would expect the properties to be populated using the values from the lower-camel-case properties received from the API.

Actual behaviour

All properties have default values, i.e. 0 or "" or null.

Additional details

See discussion at #3133.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions