Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos: Support for weakly typed json #20584

Open
IGx89 opened this issue Apr 9, 2020 · 9 comments
Open

Cosmos: Support for weakly typed json #20584

IGx89 opened this issue Apr 9, 2020 · 9 comments
Assignees
Labels
area-cosmos customer-reported punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-enhancement
Milestone

Comments

@IGx89
Copy link
Contributor

IGx89 commented Apr 9, 2020

Currently there's no good way in EF Core to work with fields in Cosmos that can contain arbitrary JSON. We would love a way to both read and write to fields like that.

The Npgsql provider appears to have elegantly solved this by adding support for JsonDocument column types (ref: http://www.roji.org/efcore-pg-advanced-json#weakly-typed-access-via-jsondocument). Having matching functionality with the Cosmos provider would be exactly what we need.

@ajcvickers
Copy link
Contributor

@AndriySvyryd I can't find the dupe for this.

@IGx89
Copy link
Contributor Author

IGx89 commented Apr 13, 2020

I did a lot of searching for dups myself before creating this :). I found similar issues, but all were vague or had replies of the sort saying this would be great but we need to wait until the other providers solve this first. Now that another provider has taken the initiative on picking a solution, hopefully it's a good time to go forward with this provider as well!

@AndriySvyryd
Copy link
Member

Most of the functionality would be covered by #17306 and #17311, albeit the API wouldn't be as nice

@IGx89
Copy link
Contributor Author

IGx89 commented Apr 13, 2020

Thanks for considering this! FromSql would work OK for reads but not well/at all for updates and creates, and a custom serializer wouldn't work for our specific use case (we already tried it) due to our use of dynamic JSON (we have a JSON object with string keys and arbitrary object values -- basically Dictionary<string, JObject>)

@IGx89
Copy link
Contributor Author

IGx89 commented Apr 13, 2020

I assume this is dependent on #18753, since JsonDocument is from STJ which Microsoft.Azure.Cosmos switches to in v4.

@ChiefInnovator
Copy link

Agreed! This would be a great feature.

@erikrenaud
Copy link

It woud be nice if we could use HasConversion to return pure json and viceversa.
I might be able to use this the issues i have because of #9630.

@ajcvickers
Copy link
Contributor

Note from triage: this needs to be done in conjunction with or after #17306.

@ajcvickers ajcvickers modified the milestones: Backlog, 7.0.0 Oct 27, 2021
@ajcvickers ajcvickers added punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. and removed propose-punt labels Jul 7, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, Backlog Jul 7, 2022
@AndriySvyryd AndriySvyryd changed the title Support for JsonDocument type in Cosmos provider Cosmos: Support for weakly typed json Apr 21, 2023
@AndriySvyryd
Copy link
Member

We should consider exposing this through Dictionary<string, object> or any type with a compatible indexer property instead of depending on a specific DOM implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-cosmos customer-reported punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-enhancement
Projects
None yet
Development

No branches or pull requests

5 participants