I'm playing with DDD and this question pop up. How I load child Aggregate Roots? Several performance issues would arise. Imagine the following example:
public AggregateRoot1
{
#region
properties
#endregion
public AggregateRoot2 AR2{get;set;}
public IEnumerable<AggregateRoot3> AR3List{get;set;}
(...)
}
If I load AggregateRoot2 and AggregateRoot3 list when I get AggregateRoot1, the graph would me massive. This not seem a nice approach.
I have two options:
- Substitute AggregateRoot2 AR2 by Guid AR2Id and IEnumerable AggregateRoot3> AR3List by IEnumerable Guid> AR3ListIds. All AR references should be substituted by the ID.
- Because i don't like the IEnumerable ARListIds approach I'm thinking in remove 0...* references to AR's. All the operations that need that AR's list data should be made through domain services like David Masters sugest here
BTW, I'm not considering using lazy loading.
I'm looking forward to ear your opinion about child AR's loading. Thanks