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

Top-level property for any changes #48

Open
krispharper opened this issue Sep 20, 2018 · 3 comments
Open

Top-level property for any changes #48

krispharper opened this issue Sep 20, 2018 · 3 comments
Assignees
Labels

Comments

@krispharper
Copy link

Apologies for opening another issue so soon. Is there a property at the change tracker level that will indicate if any changes have been made on any of the objects in the object graph? I'm hoping to use this for a "needs to be saved" indication for backing a UI.

I saw this issue, which I think would accomplish what I need, but it involves configuring a separate event on each tracked object, which is a little cumbersome.

I didn't see anything in the documentation, but maybe I'm missing something. Right now I'm basically doing something like this

entities.SelectMany(e => e.GetChangeTracker().ChangedProperties).Any();

which could be slow if there are a lot of entities or a lot of changes.

@mfidemraizer mfidemraizer self-assigned this Sep 20, 2018
@mfidemraizer
Copy link
Owner

Hey! No problem, you may ask as many questions as you need when you find issues or you've doubts!

May you explain further details about your object graph? Is the object graph a collection? Is a change tracked collection?

If I'm not mistaken, you're looking for sharing the same object change tracker across all those entities which could drive to this other issue: #41

Please answer the question so I can figure out what's going on with more precision.

Thank you in advance!

@krispharper
Copy link
Author

I am effectively looking for something similar to the HasChanges method from Entity Framework's change tracker. This gives a single place to check for any changes across all objects being tracked.

This can be nice if, for example, you have a UI backed by several different tracked objects, and you want to indicate if there are any changes that need to be saved.

I can do it manually using something like the above where I iterate over all tracked objects, call GetChangeTracker() on each one, and check ChangedProperties for any changes. But that requires keeping track of exactly which objects are being tracked and providing a common method to access them.

@mfidemraizer
Copy link
Owner

@krispharper I see, something like ChangeTracker.HasChanges.

This involves a shared change tracker across many unrelated entities. It's related to #41

It requires some effort. Let me think again about it.

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

No branches or pull requests

2 participants