mardi 31 mars 2015

What is the appropriate pattern for mapping multiple data sources to a single business object?

We have a business model and associated repository. This is populated by disparate data from different tables in a database. At some point, after the user had made changes to the data, we have to reflect those changes back to the database. Currently this is done by associating the key with the object like this:



class DataObject
{
string SomeProperty;
// more properties

int Table1Id;
int Table2Id;
int Table3Id;
}


I proposed a slight cleanup by adding a property that identifies the source table, and then using a single "ExternalId" property; but I'm wondering if there is a better pattern for this that decouples the data and business layer better.


We are using C#, but this is a somewhat language agnostic question.


Aucun commentaire:

Enregistrer un commentaire