I have a service with domain model and I want expose data to clients. Service has typical architecture: database, ORM(EF), business layer with domain model.
I want to use WCF DataServices to expose data to clients, but I can't send data objects from domain model to client. I going to use DTO to interact with clients and I have dto<=>data objects mapping.
DataServices has reflection provider which seems to be fine in this case(let's consider read-only scenario). But reflection provider require IQueryable<dto>
property to be exposed. And this is the problem. So I see following ways to solve it:
- Load all domain objects, map all of them to dtos and return result dtos. Really bad approach if there are many domain objects exists.
- Create a "linq2dto" provider and generate dynamically correspondent "linq2EF" query, at point of query materialization get data objects from db and perform mapping. Its sounds good, but as I see, it a complicated task.
So guys, I need help. I do not want to write(and support!) new one linq provider. May be there is somewhere some "general linq2anyware" realization which I can use?
From other hand, I really can't expose data objects to client and use DataServices EF provider. Is there some simple way to implement such mapping?