Issues with dynamic property
@xuzhg is already working on this.
Since Feb 1, 2021.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
- Dynamic property doesn't support non-primitive data types
We are trying to build an odata data service to enable clients to store arbitrary json data. I define an open data type by adding the following field. It works well with primitive data types like string ect.
public IDictionary<string, object> DynamicProperties { get; set; }
However, when I try to post an item with the following dynamic property.
"SortKey": {
"Timestamp": "0001-01-01T00:00:00+00:00",
"KeyValue": 0
}
I got an exception below.
The given untyped value '{"Timestamp":"0001-01-01T00:00:00+00:00","KeyValue":0}' in payload is invalid. Consider using a OData type annotation explicitly.
Is there a way to support arbitrary json data and return them as-is on request?
- Filtering dynamic property always return empty result
I posted some items with a dynamic property "type": 65. However, I always get empty result with $filter=cast(Type, 'Edm.Int32') eq 65.
I stepped into the source code. It seems like this check statement is causing the problem. It works well if I skip it under debugger.
https://github.com/OData/WebApi/blob/13938e80d0754f2e554f70c8e92fba1baeaf8318/src/Microsoft.AspNet.OData.Shared/Query/Expressions/ExpressionBinderBase.cs#L1370

Is this an known issue? Any comments are highly appreciated. Thanks!
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.
Assessment
This issue has not been assessed yet.