Accessing the same data from different view models

Topics: Questions
Jul 26, 2012 at 10:22 PM

What is the correct approach on accessing the same data from different view models?

I have a grid that displays following columns:  Project, Themes, Message.

Themes is a complex object (a hierarchy). Each message has multiple themes associated with it.

On double click on Themes column, a window opens showing all the Themes for the project. The associated themes to the message are selected.

When I make an edit on one of the themes, I would like to view the change in the grid also. How should I go about this? I would like to make the change in one place only and all my UI update, instead of doing a manually sync.

Thank you.

Jul 27, 2012 at 6:42 AM

If this is the case, you must create a service or context that contains your models. For example, if you re-use the same objectcontext in entity framework, it will return the same objects for the same id's.

So, in the end you will need to make sure that if you query model x, it will always return the same instance. That is depending on your OR mapper or model structure.