Last active
January 3, 2018 11:03
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(...); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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