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
When Instance property in OData Container Class is patched from property to expression containing
Expression.Default
orExpression.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:Work:
In the first example serialization fails only in the Default(PropertyClass) case