title: What type to return when querying multiple entities in Repository layer?
body: <p>I have the following layers involved in this question:</p>
  
  <ul>
  <li>Service Layer (Using IoC to call Repository)</li>
  <li>Domain Model (POCO / Domain Entities, defined repository Interfaces)</li>
  <li>Repository Layer (EF .edmx and implemented repositories)</li>
  </ul>
  
  <p>A lot of times it's really straight forward: Repository layer queries database via Entity Framework and returns <code>IList&lt;SomeDomainEntity&gt;</code> to caller which was Service Layer. The <em>type</em> returned is a type defined in the Domain Model.</p>
  
  <p>The problem I'm running into is when I need to query across POCOs A,B, and C and get data from all to be returned. Since I don't handle any logic in the repository I need to return this data back to the Service layer to be processed (either directly or more likely by calling some logic on domain model). However I don't have a <em>single type</em> anymore from the results of the repository query to return to the caller.</p>
  
  <p>An anonymous type of course handles this in examples I see, but since I'm not processing that logic from returned data directly in the Repository and it needs to be returned, I need a physical type to return. Here are some solutions I thought of but not sure I like any:</p>
  
  <ol>
  <li>Create a new domain entity in Domain Model that essentially is a composition of all the data I queried, so this new single type may be returned. This seems wrong to create abritrary types to satisy query needs.</li>
  <li>Make the service layer call the individual repositories on A,B,C entities separately and then deal with the data from each returned object. This seems like a lot of extra work.</li>
  <li>Create a ViewModel to return. This seems out of place to me as well. I leverage ViewModel classes heavily between my service layer and UI layers, but never seen them leveraged for return from the repository.</li>
  </ol>
  
  <p>I can't be the only one querying across multiple entities to get a conglomeration of data back that needs to be added to a type and returned to the caller. What is a common practice or standard way of going about this to solve my problem?</p>
  
  <p>Thanks!</p>