-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Expose StateManager.TryGetEntry in DbContext.ChangeTracker #33003
Comments
Since a bug (which should be fixed by 8.0.2) is preventing me from switching to EF8, I did not realise this had been implemented on DbSet().Local. Has this been implemented on DbContext.ChangeTracker? |
Duplicate of #29685 |
In my case I am working with an object that can be of any type, thus I do not know the specific type at design time. Although DbSet().Local.FindEntry is a good feature, I would still have to access it via reflection. For that reason I suggested to include StateManager.TryGetEntry (as FindEntry) in DbContext.ChangeTracker. In my opinion, this is an enhancement to #29685 rather than a duplicate. |
From DbContext.ChangeTracker, the only way to find a tracked entity by its primary key is to iterate over ChangeTracker.Entries().
Since this is not efficient, I propose exposing StateManager.TryGetEntry in DbContext.ChangeTracker (Ex: ChangeTracker.FindEntry). DbSet().Find() already employs this method to locate a tracked entity by key.
Hopefully this won't be too much effort because StateManager is already utilized in the ChangeTracker class, like StateManager.Entries().
The text was updated successfully, but these errors were encountered: