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

  • Home
  • SEARCH
  • 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 6843433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:14:40+00:00 2026-05-27T00:14:40+00:00

If I have an aggregate root which consists of say: class Parent { IEnumerable<Child>

  • 0

If I have an aggregate root which consists of say:

class Parent
{
    IEnumerable<Child> Children{ get; set; }
}

Children could contain any number of possible Child objects which are stored in the database.

What would be the best way of getting a total list of all Child objects to the application, so they can be presented in a UI allowing a user to attach/remove them from the Parent object?

Having a method in Parent such as

class Parent
{
    IEnumerable<Children> GetAllChildObjects { get; set; }
}

would surely corrupt the model with implementation details?

Would it be ok to have a domain service which calls the Parent repository and retrieves a full list. The facade to the application could then call the service directly, ensuring the Parent model stays “pure”.

Update:

To give a bit more detail, i’m tidying up a system and trying to give it some structure.

A User can hold a number of WorkLocations. WorkLocations are pretty simple. The current system contains a webpage which displays user details including a full list of valid WorkLocations. Selecting locations from the list updates the User model with the new locations.

Currently, the UI pretty much hits the DB and pulls out the full list of WorkLocations. I need to pull this back into a more structured form.

Or, does this suggest that WorkLocation should not be in the User root as it currently is?

  • 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-27T00:14:41+00:00Added an answer on May 27, 2026 at 12:14 am

    Am I correct in thinking that you want all the WorkLocations from the database, regardless of what User they are attached to (if any)?

    If so I would definitely go for the service approach, something like:

    public interface IWorkLocationsService
    {
        IEnumerable<WorkLocation> GetAllWorkLocations();
    }
    

    You might want WorkLocation to be immutable so that all changes to them go through User, though I suspect this isn’t necessary here.

    Update:

    You could then add the following methods to User

    // This gets filled from the db somehow.
    private IList<WorkLocation> workLocations;
    
    // IEnumerable so that all external additions and
    // removals must go through dedicated methods.
    public IEnumerable<WorkLocation> WorkLocations
    {
        get { return workLocations; }
    }
    
    public void AddWorkLocation(WorkLocation locationToAdd)
    {
        workLocations.Add(locationToAdd);
        // Do whatever else you need to, i.e. mark the item for saving.
    }
    
    public void RemoveWorkLocation(WorkLocation locationToRemove)
    {
        workLocations.Remove(locationToRemove);
        // Do whatever else you need to, i.e. mark the item for saving.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Person class which is root of its aggregate, this aggregate also contains
Lets say I have an Illustration entity which is an aggregate root. That entity
I'm struggling with aggregates and aggregate roots. I have a natural aggregate root which
lets say i have a BlogPost aggregate root. it holds a List <Comment> .
I have an aggregate root which is a WallPost. A WallPost can have zero
I have an aggregate root called Configuration which represent's all the options configured for
VB.NET .NET 3.5 I have an aggregate class called Package as part of a
I have a class TContainer that is an aggregate of several stl collections pointers
I have a database for which I need to aggregate records into another smaller
I have an aggregate root Order with corresponding OrderService and OrderRepository . I have

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.