sorry for my English.
I previously posted this question as: Multiple ViewModels request same domain object, should I give them the same/different instance(s)?
After I did some research on this, I realized my previous question was too confusing, so I post this new question.
Let's say I want to build a WPF desktop application to manage the information of 1 billion persons. It has only one end user (me), and all data is stored in my local machine (SQL Server / MySQL). I'm going to use Visual Studio, Autofac, NHibernate, and try to implement MVVM, DI, DDD patterns.
The same person could simultaneously displayed anywhere in the UI: in multiple windows, tabs, lists, comboboxes, textblocks... Each list could contain a few thousands persons, and the whole application could have 10~100 lists. And the contents (persons) of the lists get updated frequently: Each time I change the settings of a list, the list gets emptied, then filled with another several thousands of new persons.
The problem is: If I modify a person (eg. change name) in one list, how to apply the changes to all other lists?
I think there are 2 ways to solve this problem:
For each person, use a single instance through the entire application. To implement this, I can use a single UnitOfWork through the application, but it seems this approach would cause memory leak.
Use multiple instances for each person (one instance per list). To implement this, I think I should use one UnitOfWork for each list, and I must find a way to synchronize all instances of a person. Berryl mentioned event aggregator. But who is responsible to publish and register the events?
I found a very similar question at here, and also read the following articles, but I still feel confused:
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…