Lets assume I load some business collections eagerly with NHibernate, EF or any ORM tool you wish...
Now I have an IList where each Customer has many Orders and each Order has many Products.
You have a GetAllCustomer() method in your CustomerRepository.
WHERE do you and HOW do you aggregate all your data into THREE ObservableCollections of type
Customer, Order and Product because I need add/delete notification events !?
Do you really do something like that in the BillingViewModel where you execute the customerRepo.GetAllCustomer():
BillingViewModel.cs
private ObservableCollection<Customer> _customersOC = new ObservableCollection<Customer>();
public BillingViewModel()
{
var customers = customerRepo.GetAllCustomer();
ConvertDomainToUICollections(customers);
}
private ConvertDomainToUICollections(IList<Customer> customers)
{
foreach(Customer c in customers)
{
_customersOC.Add(c);
foreach(Order o in c.Orders)
{
// Here I do not know how to proceed and put each in another OC<Order> etc...
}
}
}