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 577581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:10:07+00:00 2026-05-13T14:10:07+00:00

If I have an Order class an as aggregate root and 1000 line items.

  • 0

If I have an Order class an as aggregate root and 1000 line items.

How do I load just one of the 1000 line items? As far as I understand, a line item can only be accessed through the Order class and has a “local” identity. Would I still create a repository method at the OrderRepository like “GetLineItemById”?

Edit to comment the answer:
Currently I don’t think it’s reasonable to have an immutable children. What if I have an Customer class with several addresses, contracts and even more child collections. A huge entity I want to perform CRUD methods on.

I would have

public class Customer
{
    public IEnumerable<Address> Addresses { get; private set; }
    public IEnumerable<Contracts> Contracts { get; private set; }
    ...
}

Would I have to do something like this if a user corrects the street of an address or a property of a contract?

public class Customer
{
    public void SetStreetOfAddress(Address address, street){}

    public void SetStreetNumberOfAddress(Address address, streetNumber){}
}

The customer class would be full of child manipulation methods then. So I would rather do

addressInstance.Street = "someStreet";

I think I am misunderstanding the whole concept.. 🙂

  • 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-13T14:10:08+00:00Added an answer on May 13, 2026 at 2:10 pm
    1. There’s nothing wrong with accessing children of an aggregate root via simple, read-only properties or get methods.

    The important thing is to make sure that all interactions with children are mediated by the aggregate root so that there’s a single, predictable place to guarantee invariants.

    So Order.LineItems is fine, as long as it returns an immutable collection of (publicly) immutable objects. Likewise Order.LineItems[id]. For an example see the source for the canonical Evans-approved ddd example, where the aggregate root Cargo class exposes several of its children, but the child entites are immutable.

    1. Aggregate roots can hold references to other aggregate roots, they just can’t change each other.

    If you have "the blue book" (Domain-Driven Design), see the example on page 127, which shows how you might have Car.Engine, where both Car and Engine are aggregate roots, but an engine isn’t part of a car’s aggregate and you can’t make changes to an engine using any of the methods of Car (or vice-versa).

    1. In domain-driven design, you don’t have to make all your classes aggregate roots or children of aggregates. You only need aggregate roots to encapsulate complex interactions among a cohesive group of classes. The Customer class you proposed sounds like it shouldn’t be an aggregate root at all – just a regular class that holds references to Contract and Address aggregates.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 287k
  • Answers 287k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try multiplying it by small integers in a loop and… May 13, 2026 at 5:09 pm
  • Editorial Team
    Editorial Team added an answer I don't think there's anything wrong with the parser regarding… May 13, 2026 at 5:09 pm
  • Editorial Team
    Editorial Team added an answer This question was asked before: https://stackoverflow.com/questions/1109838/recommend-portable-source-control-setup and Version control on… May 13, 2026 at 5:09 pm

Related Questions

I have a method that takes an array of queries, and I need to
I have an Order class which goes through a series of defined states. To
I have a product image class. This is an object with re-use potential for
I have a design question concerning Django. I am not quite sure how to
I'm not sure if what I'm even trying to do is possible but here

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.