EF6 & SQL Server 2008 > DTOs based on multiple independent Entities

Posts   
 
    
costa_b
User
Posts: 3
Joined: 25-May-2017
# Posted on: 25-May-2017 19:34:40   

Hi:

I played a bit with Derived Models -> DTOs and I couldn't find a way to derive the data in a DTO based on multiple independent entities. It was ok as long as I could get to an entity via relationships starting with the Source entity.

I have a lot of scenarios where the data in a DTO is pulled from queries that join tables and views. Does it make sense to link tables and views? I would think not... The views are of data from another system (sometimes via linked servers) and to get some of that data I have to join based on certain fields. You could argue that the design should have been done differently to begin with and I might agree, but it is what it is, that's how it was done. And in my mind there should be a way to derive DTOs based on anything. That's the reason d'etre for DTOs. Otherwise I might as well code them by hand.

Perhaps there is a way and I missed something...

Thanks !

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-May-2017 07:54:12   

If you want to use various entities on a derived element (dto) they must be related between them. If you don't have them related already, you have some options:

A. Write a view on your DB that uses the joins you want, and reverse engineer it to a Entity in LLBLGen Designer.

B. Reverse engineer the Table into an Entity, and the involved DB View into an Entity, then create a relationship between them in LLBLGen.

David Elizondo | LLBLGen Support Team