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

support get_item in JsonObject #3321

Open
vmachacek opened this issue Jun 30, 2022 · 1 comment · May be fixed by #4856
Open

support get_item in JsonObject #3321

vmachacek opened this issue Jun 30, 2022 · 1 comment · May be fixed by #4856
Assignees
Labels
feature-request New feature or request LINQ QUERY

Comments

@vmachacek
Copy link

I have a migrations for which i describe query in a form of Expression<Func<JsonObject, bool>> and this expression will get translated to SQL and sent to cosmos and than the migration run on subset of database. So far so good. Now i have migrated most of the codebase to the System.Text.Json I want to make this work with JsonObject instead of JObject

Now something like this wont work because expression visitor is complaining about get_Item method not supported

 var key = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==";
var client = new CosmosClient("https://localhost:8081/", key);
var container = client.GetContainer("wont-be-needed", "does-not-matter");

IOrderedQueryable<JsonObject> queryable = container.GetItemLinqQueryable<JsonObject>();
IQueryable<JsonObject> queryable1 = queryable.Where(f => (string)f["id"] == "fooBar");

queryable1.ToQueryDefinition();

https://gist.github.com/vmachacek/09d27a9f552bc94e3d7b11453b67f94e

I want query defined as (string)foobar["prop"] == "bar" work with JsonObject same as it is working with JObject

I have considered keeping dependency on Newtonsoft.

Broader question is what are the plans for integrating System.Text.Json into the SDK, or what course of action i should take?

exception Method 'get_Item' is not supported., Windows/10.0.22000 cosmos-netstandard-sdk/3.28.2

@Maya-Painter
Copy link
Contributor

Right now, the System.Text.JSON package depends on the Azure.Core version 1.19.0, which uses the STJ version 4.6.0. The JsonNode type was introduced in a later package, so we aren't able to support this LINQ to SQL translation at this time.

Newtonsoft will continue to be the default serializer for V3 of the .NET SDK. We should be able to support this scenario in V4, or when the Azure.Core version is upgraded.

@Maya-Painter Maya-Painter self-assigned this Jun 14, 2024
@Maya-Painter Maya-Painter linked a pull request Oct 26, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request LINQ QUERY
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants