title: WCF DataServices & Mapped DTOs
body: <p>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. </p>
  
  <p>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&lt;=>data objects mapping. </p>
  
  <p>DataServices has reflection provider which seems to be fine in this case(let's consider read-only scenario). But reflection provider require <code>IQueryable&lt;dto&gt;</code> property to be exposed. And this is the problem. So I see following ways to solve it: </p>
  
  <ol>
  <li>Load all domain objects, map all of them to dtos and return result dtos. Really bad approach if there are many domain objects exists.</li>
  <li>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.</li>
  </ol>
  
  <p>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?</p>
  
  <p>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?</p>