i am designing the object model an application and there is certaint level of impedance mismtach between objects and tables. For example I have :
Product
-----------
ProductId,
ProductTypeCode,
StatusCode,
SKUNumber
ProductMarketAvailability
--------------------------
ProductMarketAvailabilityId,
ProductId,
MarketId,
Rank
ProductDescription
------------------
ProductDescriptionId,
ProductId,
MarketId,
StatusId,
DescriptionTypeId,
Description
(i didnt illustrate lookup tables:Status,DescriptionType,ProductType,Market)
I want to have a DOMAIN CLASS:
Product
--------------
ProductId,
SkuNumber,
MarketId,
MarketName,
StatusCode,
Status,
Title ,
Description,
Caption,
Rank
With LLblGen pro or Entity Framework :
- how i can map these tables my domain class?
- Is it a best way to deal with this through Domain classes or better to
isolate domain classes from ORM generated classes
- If I manually map ORM classes data to my domain classes then when i
persisting my Domain classes (imagine they are POCO Self tracking),
how can i write managable , well crafted code ?
i dont want to write , it doesnt look so right to me:
if (myProduct.TitleisDirty)
{
ProductDescription p= myRepository.GetDescriptionById
(myProduct.ProductDescriptionIdForTitle);
p.Description=myProduct.Title;
p.SubmitChanges();
}
if (myProduct.RankisDirty)
{
ProductMarketAvailability pma= myRepository.GetMarketById
(myProduct.ProductMarketAvailabilityId);
pma.Rank=myProduct.Rank;
pma.SubmitChanges();
}
Thank you very much for reading.