Reputation: 33994
Let's say I have 2 tables, Page
and Application
.
Page always belongs to an application, so Application.ID = P.ApplicationID.
I have 2 domain model classes Page
and Application
. Now in my Service Layer, I need to get a Page and its Application
properties. So, how to handle this situation? Whether I need to create a composite model? I have search a lot but could not found any and I am stuck here.
Upvotes: 0
Views: 365
Reputation: 7412
Since a Page is always associated to an Application, you're application object might have a List<Page> Pages
property. If so, then you can return your Application object, with the appropriate Page populated in that list.
If you're Application does not contain a List Pages property, it seems logical from your (short) explanation that it probably should. If you can modify the object to include a List then you are in the same position as above and you are good.
If for some reason, it does not have a List Pages property, and you cannot modify it to include one (perhaps it doesn't make sense in the bigger picture, perhaps you do not control the object), then you are right to create a simple composite class that has two properties Page and Application.
Upvotes: 2