Skip to content

Instantly share code, notes, and snippets.

@phillippelevidad
Last active January 3, 2018 11:03
Show Gist options
  • Save phillippelevidad/9522af3c3c65f8c84698fbd62a47529c to your computer and use it in GitHub Desktop.
Save phillippelevidad/9522af3c3c65f8c84698fbd62a47529c to your computer and use it in GitHub Desktop.
DDD: aggregate embedding the root entity's properties or with a reference to root entity?
// Aggregate has a reference to its root entity.
public class WebAppAggregate : Aggregate
{
public Guid Id; // Aggregate Id.
public WebAppEntity WebApp;
public WebAppAggregate(Guid id, WebAppEntity webApp);
public Result SomeInvariant(...);
}
public class WebAppEntity : Entity
{
public Guid Id; // Entity Id.
public string Name;
public Url Url;
public WebAppEntity(string name, Url url);
public Result AnotherInvariant(...);
}
// Aggregate embedding the root entity's properties.
public class WebAppAggregate : Aggregate
{
public Guid Id;
public string Name;
public Url Url;
public WebAppAggregate(Guid id, string name, Url url);
public Result SomeInvariant(...);
public Result AnotherInvariant(...);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment