c# - DDD and CRUD on lookup tables using repository pattern -
so trying follow domain driven design approach , not sure how handle lookup tables require crud operations. here contrived example demonstrate question.
let's have person class
public class person { public string address { get; private set; } }
my database has table of people , table of addresses. people table has column address_id foreign key address table. obvious idea being can't add person record people table address value doesn't exist in addresses table since there foreign key relationship.
in application, person aggregate root , has associated repository. using repository, load people loads associated address.
my question how do crud operations on addresses table? following ddd principles, don't think supposed create repository addresses table.
the requirement application when creating new person object, drop-down list of addresses presented user select address. not allowed hand type addresses, must pick 1 exists. hence, crud operations on addresses table. administrator of system need manage addresses lookup table proper selections presented user creating person objects.
again, contrived example , nobody ever design such system. illustrate question.
are ever editing or retrieving addresses on own? repository mapper business object relational database, supposed encapsulate how object persisted don't have worry it.
if object persisted in multiple tables business logic not have know that, unless needed edit address objects on own, wouldn't add repository address.
have @ this: repository pattern step step explanation
Comments
Post a Comment