-
Notifications
You must be signed in to change notification settings - Fork 64
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
Updates cause all properties of an entity to be marked as modified #188
Comments
I think the reason is that the I wouldn't want to change this default behavior, because it might break some existing Breeze applications, but it might make sense to make it configurable via something in BreezeConfig. |
That makes sense. Would you be willing to accept a PR for this change? |
Yes please! A PR would be great. |
@christianacca Have you made any progress on this? |
Nope! started this weekend building out some test cases around owned entities. Realistically, I would be surprised if I'm able to get a working PR in the next 4 weeks. |
We have this scenario and so far I haven't been able to come up with a workaround. Some of our entities are mapped to database views and they can be edited on the client. When the changes reach the server we have some bits of infrastructure that "convert" the view entities to their table mapped counterparts. Setting the state to unchanged in I'm thinking that "accepting" changes (by manipulating LE: seems to be working var entry = _context.ChangeTracker.Entries().FirstOrDefault(entry => entry.Entity == convertedEntity);
foreach (var property in _context.Model.FindEntityType(convertedEntity.GetType()).GetProperties())
{
var current = entry.CurrentValues[property];
var original = entry.OriginalValues[property];
if (current != original)
{
entry.OriginalValues.SetValues(new Dictionary<string, object>()
{
{ property.Name, current },
});
}
} |
@iulianb I've also faced a case where I had to update "view" entities on the client. Ultimately I handled it on the client: when it was time to save, I queried the appropriate table entities corresponding to the changed view entities, updated them, and saved them. This is easier than removing and adding entities in To handle it in It reminds me a bit of this StackOverflow answer, but of course this is a different problem. |
That is exactly what we're doing in the converters, which are basically command handlers executed before the handlers for create/update/delete. We've opted for this approach because in some scenarios the conversion is not 1 to 1 (eg. one view entity needs to be saved to multiple tables) and we wanted to provide developers with some degree of control over how the conversion happens. After conversion the entities go through the create/update/delete flow as there might be other implementation details, depending on the entity. As stated in the previous reply, the issue is on updated view entities. Their table counterparts are automatically tracked by EF when queried and any property update on them ends up in the state tracker. When the entity state is set to |
When an
EntityInfo
whose state is modified is processed byEFPersistenceManager.HandleModified
all properties in the corresponding EF Core EntityEntry is marked as being modified.The exact line that causes this is in
MarkEntryAndOwnedChildren
:I'm not entirely sure this is a bug or by design? It seems unintentional given the comment here:
There was an old related issue but @jtraband closed that one but wasn't sure why?
I wonder if this behaviour can be changed such that not all properties are modified? Or maybe a configuration option to allow this behaviour?
The text was updated successfully, but these errors were encountered: