Projection query ($select) result ("non-EDM approach") does not adhere to API serialization options with System.Text.Json.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
I have tested migrating our API from Microsoft.AspNetCore.OData 7.x to 8.x.
In version 7.x, it was required to configure the MVC to use NewtonSoftJson (IMvcBuilder.AddNewtonSoftJson), instead of System.Text.Json which is used by default for JSON serialization in AspNetCore.
My earlier experience with our applications that uses a "non-EDM approach", was that everything actually worked fine even with System.Text.Json - apart from projection queries ($select), where the results were not properly serialized.
When upgrading to version 8.0.1, I wanted to test if projection queries work without NewtonSoftJson, and now it seems like it mostly works, apart from the following behavioral difference:
Our API is configured to use camelCase conversion in the MVC serialization options. (Before my testing this behavior was configured through the NewtonSoft options, now I configure the same MVC behavior for the System.Text.Json options).
I noticed that when using NewtonSoftJson, projection query results adhered to these options, and the properties of the "dynamic" projection query results were converted to camelCase. When switching to System.Text.Json (default), these properties had not been case-converted.
I hope this can be fixed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing a non-EDM projection query using $select with System.Text.Json and MVC camelCase serialization options, then compare its dynamic result with the NewtonsoftJson behavior described. Trace the projection serialization path; done means projected properties are converted to camelCase according to the configured System.Text.Json options.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100