title: Is AutoMapper/ValueInjector really needed for Entity to ViewModel mapping?
body: <p>I wonder if it is really needed to use some object-to-object mapper, when mapping entity framework entities to ViewModels. Samples around generally shows 1-entity mapping to 1-viewmodel. But real-life is usually different; because we generally need to join multiple tables and choose some columns from each. (I use POCO entities and ASPNET MVC) Here is what i always use to map my linq query result to ViewModels.</p>
  
  <pre><code>public List&lt;MyViewModel&gt; GetSomeDataForView(string filter1)
      {
          using (MyEntities context = GetMyEntites())
          {
              var query = (from t1 in context.Table1
                           join t2 in context.Table2 on t2.Table1Id equals t1.Id
                           join t3 in context.Table3 on t3.Table2Id equals t2.Id
                           where t1.FilterColumn=filter1
                           select new MyViewModel
                           {
                               Property1 = t1.Column1,
                               Property2 = t1.Column2,
                               Property3 = t2.Column1,
                               Property4 = t3.Column1
                           });
  
              return query.ToList();
          }
      }
  </code></pre>