How can I convert persistant objects to DTOs using the projects generated with the "Generate OpenAccess Domain Model Service" wizard? I have attempted to use the Assembler classes, however they do not assemble any of the child objects:
public
IEnumerable<CountryDto> FetchCountryHeirarchy()
{
using
(var context =
new
GlobalResourcesEntitiesModel())
{
FetchStrategy strategy =
new
FetchStrategy();
strategy.LoadWith<Country>(c => c.States);
strategy.LoadWith<State>(s => s.Cities);
context.FetchStrategy = strategy;
IQueryable<Country> items = from c
in
context.Countries
select c;
CountryAssembler ass =
new
CountryAssembler();
return
ass.Assemble(items);
}
}
I have the following projects:
- MyApp.ActionService (hosts complex business actions / operations)
- MyApp.DataService (created by TelerikORM for CRUD operations)
- MyApp.Business (used for complex operations)
- MyApp.Data (EntityModel is here)
My goal is to pass the same DTO objects from either service. This allows me to protect the data service from direct data calls and expose a more complex operation with the ActionService. My hope is to encapsulate all of the complex operations in either the ActionService or Business layer project while still passing the DTOs that Telerik ORM has generated in the Data Service.
At the moment, both the Business layer project and ActionService are using standard LINQ syntax against the EntityModel (context) directly. This returns the objects from the RLINQ file and NOT the DTOs. I would like to convert them to DTOs before sending them across the wire.
Thanks, in advance.
- Greg D.