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

Related Questions

Using LINQ to SQL, I have an Order class with a collection of OrderDetails.
I have a 'Purchase Order' class. It contains information about a single purchase order.
I have been using the partial class modifier for some time in order to
I have a View class (OrderView.aspx) which shows the details of an order (Account
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end
Suppose I have a class 'Application'. In order to be initialised it takes certain
In order to reference a member of a class in XML comments/documentation, you have
Let's say I have a basic class A that aggregate B and C: class
Let's say we have: @Entity public class Order { @Id private int id; @OneToMany(mappedBy=order)
After user places an order I have to send detailed email message containing order

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.