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
#6560 - EFRepositoryBase - Unnecessary call to Update or UpdateAsync causes whole entity to be marked dirty #6561
base: dev
Are you sure you want to change the base?
Conversation
@gentledepp thank you for your contribution. When I check your PR, below unit tests are failing;
|
344e852
to
e8e683e
Compare
Please check my changes on the tests. I tried to add comments to make my point clear.
The line How should this be resolved? |
…ate to "Modified" this ensures, that unnecessary calls to "UpdateAsync" result in the whole entity being set "dirty" as opposed to just the properties that changed!
e8e683e
to
798cd96
Compare
// in case no entity was changed, but only a relationship between entities... | ||
foreach(var relationshipOnlyChange in relationshipChanges.Where(rc => context.ChangeTracker.Entries().All(ent => ent.Entity != rc.Entity))) | ||
{ | ||
// TODO: implement this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem lies here.
In case only a relationship was changed, but none of the actual entities, we need to track the changes too.
Because comments and posts are connected using an implicit N:M table (Comments_Posts) I have no way to get all the details necessary, though.
Can you give me a suggestion in how to implement this?
I would need:
to get from the Comments_Posts EntitySet
to the entities Comment and Post, but the API of ObjectStateEntry seems not to allow for that.
Otherwise I have no way of knowing whether one of those entities is actually audited or not :-|
#6560 - EFRepositoryonlyBase - if entity had to be attached, we do set its state to "Modified"
this ensures, that unnecessary calls to "UpdateAsync" result in the whole entity being set "dirty" as opposed to just the properties that changed!