Instance expression Expression.Default, Expression.Convert(Expression.Constant(null),typeof(DesiredObject)) fails during serialization
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
When Instance property in OData Container Class is patched from property to expression containing Expression.Default or Expression.Convert(Expression.Constant(null),typeof(DesiredObject)) serialization fails with the following error:
the EDM instance of type [some-type] is missing the property [some-property]
Doesnt work:
Container = new SingleExpandedProperty`1() {
Name = "Property",
Value = new SelectAll`1() {
Model =
value(Microsoft.AspNetCore.OData.Query.Container.LinqParameterContainer+TypedLinqParameterContainer`1[Microsoft.OData.Edm.IEdmModel]).TypedProperty,
**Instance = IIF($it.Property.IsAllowed, $it.Property, default(PropertyClass)),**
UseInstanceForProperties = True},
IsNull = ($it.Property == null)}
Work:
Container = new SingleExpandedProperty`1() {
Name = "Property",
Value = new SelectAll`1() {
Model =
value(Microsoft.AspNetCore.OData.Query.Container.LinqParameterContainer+TypedLinqParameterContainer`1[Microsoft.OData.Edm.IEdmModel]).TypedProperty,
**Instance = $it.Property,**
UseInstanceForProperties = True},
IsNull = ($it.Property == null)}
In the first example serialization fails only in the Default(PropertyClass) case
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 the failure with the OData Container Class using Expression.Default and Expression.Convert(Expression.Constant(null), typeof(DesiredObject)), then compare it with the working direct $it.Property instance. Trace how SingleExpandedProperty and SelectAll serialize the Instance expression and identify why the default case omits an EDM property. Done means both reported expression forms serialize without the missing-property error.
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
- 45/100