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

ExecuteUpdate: support partial updating inside JSON documents #28766

Open
Tracked by #31238
roji opened this issue Aug 17, 2022 · 7 comments
Open
Tracked by #31238

ExecuteUpdate: support partial updating inside JSON documents #28766

roji opened this issue Aug 17, 2022 · 7 comments

Comments

@roji
Copy link
Member

roji commented Aug 17, 2022

ctx.blogs.ExecuteUpdate(s => s.SetProperty(b => b.SomeJsonDocument.Foo, b => "foo");

Things get interesting when there are multiple updates inside the same JSON document:

ctx.blogs.ExecuteUpdate(s => s
    .SetProperty(b => b.SomeJsonDocument.Foo, b => "foo")
    .SetProperty(b => b.SomeJsonDocument.Bar, b => "bar");

We could apply the same logic we're discussing for SaveChanges:

  1. Do "least-common-denominator" to find the smallest branch containing all the properties to be updated.
  2. As a further optimization, nest multiple invocations (e.g. of JSON_MODIFY for SQL Server) to update the two properties; but we need to investigate and benchmark to know to what extent that makes sense and when.
@smitpatel
Copy link
Member

cc: @maumar :trollface:

@roji
Copy link
Member Author

roji commented Aug 17, 2022

image

@roji
Copy link
Member Author

roji commented Nov 20, 2023

Also consider updating nested JSON arrays when working on this, both primitive and non-primitive.

@roji
Copy link
Member Author

roji commented Dec 5, 2023

Also make sure updating the JSON column itself works (as opposed to a partial update inside it). This will probably require extra work.

@roji
Copy link
Member Author

roji commented Jan 22, 2024

@nasisakk your Entry type seems to be a top-level entity type (as it's directly on the context), and therefore not an actual JOSN owned entity - so this doesn't seem relevant... It's also hard to see how having [JsonIgnore] would change anything here.

Can you please open a separate issue with a runnable, minimal code sample?

@onionhammer

This comment was marked as resolved.

@roji

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants