Skip to content
New issue

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

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

Already on GitHub? # to your account

Cosmos: ReadItem should be used for Reload #33893

Open
ajcvickers opened this issue Jun 4, 2024 · 1 comment
Open

Cosmos: ReadItem should be used for Reload #33893

ajcvickers opened this issue Jun 4, 2024 · 1 comment
Assignees
Labels
area-change-tracking area-cosmos area-query punted-for-9.0 Originally planned for the EF Core 9.0 (EF9) release, but moved out due to resource constraints. type-enhancement
Milestone

Comments

@ajcvickers
Copy link
Contributor

Same repro code as for #33881. Do:

await context.Entry(x).ReloadAsync();

This could be a ReadItem, but is actually:

      SELECT VALUE {"Id" : c["Id"], "Discriminator" : c["Discriminator"], "Title" : c["Title"], "id0" : c["id"], "" : c}
      FROM root c
      WHERE ((c["Discriminator"] = "Post") AND (c["Id"] = @__p_0))
      OFFSET 0 LIMIT 1
@ajcvickers ajcvickers self-assigned this Jun 4, 2024
ajcvickers added a commit that referenced this issue Jun 7, 2024
Part of #20693
Part of #33893

There is a lot left to do here, but I'm making a break here to get reviews before it goes too far.

Major changes here are:
- Discover and record properties used to form the JSON `id` in one place.
- Use this to generate ate `id` values without tracking an instance. (Makes no-tracking work, needed for Reload.)
- Be better at detecting only detecting patterns we can later translate.

Next up: be better at detecting non-Find query patterns that we can translate.
ajcvickers added a commit that referenced this issue Jun 7, 2024
Part of #20693
Part of #33893

There is a lot left to do here, but I'm making a break here to get reviews before it goes too far.

Major changes here are:
- Discover and record properties used to form the JSON `id` in one place.
- Use this to generate ate `id` values without tracking an instance. (Makes no-tracking work, needed for Reload.)
- Be better at detecting only detecting patterns we can later translate.

Next up: be better at detecting non-Find query patterns that we can translate.
ajcvickers added a commit that referenced this issue Jun 14, 2024
Part of #20693
Part of #33893

There is a lot left to do here, but I'm making a break here to get reviews before it goes too far.

Major changes here are:
- Discover and record properties used to form the JSON `id` in one place.
- Use this to generate ate `id` values without tracking an instance. (Makes no-tracking work, needed for Reload.)
- Be better at detecting only detecting patterns we can later translate.

Next up: be better at detecting non-Find query patterns that we can translate.
ajcvickers added a commit that referenced this issue Jun 15, 2024
Part of #20693
Part of #33893

There is a lot left to do here, but I'm making a break here to get reviews before it goes too far.

Major changes here are:
- Discover and record properties used to form the JSON `id` in one place.
- Use this to generate ate `id` values without tracking an instance. (Makes no-tracking work, needed for Reload.)
- Be better at detecting only detecting patterns we can later translate.

Next up: be better at detecting non-Find query patterns that we can translate.
ajcvickers added a commit that referenced this issue Jun 15, 2024
* Support ReadItem for no-tracking queries

Part of #20693
Part of #33893

There is a lot left to do here, but I'm making a break here to get reviews before it goes too far.

Major changes here are:
- Discover and record properties used to form the JSON `id` in one place.
- Use this to generate ate `id` values without tracking an instance. (Makes no-tracking work, needed for Reload.)
- Be better at detecting only detecting patterns we can later translate.

Next up: be better at detecting non-Find query patterns that we can translate.

* Updated version, based on Andriy's comment.

* Code review updates.
@ajcvickers ajcvickers added this to the 9.0.0 milestone Jun 15, 2024
@roji
Copy link
Member

roji commented Jul 6, 2024

This is effectively a special case of #34163, which is about using ReadItem when a projection is present, i.e. the whole entity isn't getting projected out (will keep this open to track as a separate user-facing scenario).

The incoming query generated by Reload:

DbSet<Item>()
    .AsNoTracking()
    .IgnoreQueryFilters()
    .Where(e => EF.Property<int>(e, "Id") == __p_0 && EF.Property<string>(e, "PartitionKey") == __p_1)
    .Select(e => new object[]
    { 
        (object)(int)EF.Property<int>(e, "Id"), 
        (object)(string)EF.Property<string>(e, "PartitionKey"), 
        (object)(string)EF.Property<string>(e, "Discriminator"), 
        (object)(string)EF.Property<string>(e, "__id"), 
        (object)(JObject)EF.Property<JObject>(e, "__jObject") 
    })
    .FirstOrDefault()

@roji roji modified the milestones: 9.0.0, Backlog Jul 6, 2024
@roji roji assigned roji and unassigned ajcvickers Jul 6, 2024
@ajcvickers ajcvickers added the punted-for-9.0 Originally planned for the EF Core 9.0 (EF9) release, but moved out due to resource constraints. label Jul 29, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area-change-tracking area-cosmos area-query punted-for-9.0 Originally planned for the EF Core 9.0 (EF9) release, but moved out due to resource constraints. type-enhancement
Projects
None yet
Development

No branches or pull requests

2 participants