Say I have a Car and a Company object:
CarModel
{
int Id;
string Name;
CompanyModel MadeBy;
}
CompanyModel
{
int Id;
string Name;
}
These are two separate domain objects, each with their own repository.
However when I store a car, I’m not actually including the Company object as well - I only store the id. In that sense I also have a CarEntity object:
CarEntity
{
int Id;
string Name;
int MadeByCompanyId;
}
But when I read a car into my application, it is more useful to be dealing with the CarModel I defined at the start, which has all the details I need like the company name of who made it.
- Should my car repository methods deal with CarModel and do mappings to and from CarEntity inside (which would involve using CompanyRepository inside the CarRepository which sounds yucky)?
- Should my car repository only deal with CarEntity and mapping to CarModel is done by the caller?
Aucun commentaire:
Enregistrer un commentaire