Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3840788
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:34:13+00:00 2026-05-19T15:34:13+00:00

Lets assume I load some business collections eagerly with NHibernate, EF or any ORM

  • 0

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...
        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:34:13+00:00Added an answer on May 19, 2026 at 3:34 pm

    Personally, I try to aggregate data like this only when required, and at the “lowest level” possible.

    For example, in the BillingViewModel, I’d do an aggregation like this for Customers. However, I wouldn’t do Orders here – but rather, handle this within the CustomerViewModel, since I’d try to set it up so that I edit Orders on a specific Customer.

    If you need to do this at the very high level, you’ll effectively be rewriting your entire Model. This can be done, but it really reduces the usefulness and maintainability of your data, since you’re effectively maintaining two full versions of the Model at a very high level.

    That being said, many ORMs handle this much more nicely for you. For example, Lightspeed (one of my favorites) just makes their collections automatically implement INotifyCollectionChanged straight from the ORM. This makes it unnecessary to convert into ObservableCollection<T> – you can just use the data as returned from the ORM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.