title: AutoMapper: How to map between Linq Expressions (Func<>)
body: <p>I am using repository pattern, so my repository just know about DTOs. It has to query the database with some filters using Entity Framework.
  My problem is that Entity Framework only knows about DB model classes, so I have to 'automap' the <em>Expression</em> before being able to use them in any query.</p>
  
  <p>I have declared a method that accepts a <em>Expression</em> as a filter.</p>
  
  <pre><code>public interface IRepository
  {
      IEnumerable&lt;ItemDTO&gt; GetItemsWithFilter(Expression&lt;Func&lt;ItemDTO, bool&gt;&gt; filter)
      {
          var filterDb = Mapper.Map&lt;Expression&lt;Func&lt;ItemDB, bool&gt;&gt;&gt;(filter);
          return dbContext.CONFIGURATIONS.Where(filterDb).Select(x =&gt; Mapper.Map&lt;ItemDTO&gt;(x));
      }
  }
  
  public class ItemDTO
  {
     public int numero { get; set; }
     public string name { get; set; }
  } 
  
  public class ItemDB //they are both the same, just for testing purpose
  {
     public int numero { get; set; }
     public string name { get; set; }
  }
  
  //failing code 
   Repository.GetItemsWithFilter(x =&gt; x.name=="a");
  </code></pre>
  
  <p>I followed <a href="https://github.com/AutoMapper/AutoMapper/blob/master/docs/Expression-Translation-(UseAsDataSource).md" rel="nofollow noreferrer">tutorial</a> that says it is possible to map between expressions but i get some errors:</p>
  
  <blockquote>
    <p>"The specified type member 'name' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."}</p>
  </blockquote>