OData / OData/AspNetCoreOData

Issues with dynamic property

Open
#81 4 comments 0 reactions 1 assignee View on GitHub

@xuzhg is already working on this.

Since Feb 1, 2021.

followup
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

  1. 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?

  1. 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
image

Is this an known issue? Any comments are highly appreciated. Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.