title: OData with EF and automapper: Cannot compare..'. Only primitive types, enumeration types and entity types are supported
body: <p>Had an Odata v3 endpoint with ef 6.1.3 and automapper 6.1.1. </p>
  
  <p>Datamodel,</p>
  
  <ul>
  <li><p>Order, one to many with Orderlines</p>
  
  <p>public partial class Order
  {
      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
      public Order()
      {
          this.OrderLines = new HashSet();
      }</p>
  
  <pre><code>public System.Guid OrderID { get; set; }
  public string OrderPlacedBy { get; set; }
  public Nullable&lt;System.DateTime&gt; PlacedTime { get; set; }
  
  [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
  public virtual ICollection&lt;OrderLine&gt; OrderLines { get; set; }
  </code></pre>
  
  <p>}</p></li>
  <li><p>OrderLines</p>
  
  <p>public partial class OrderLine
      {
          public System.Guid OrderLineID { get; set; }
          public Nullable OrderID { get; set; }
          public Nullable Amount { get; set; }</p>
  
  <pre><code>    public virtual Order Order { get; set; }
  }
  </code></pre></li>
  </ul>
  
  <p>AutoMapper code,</p>
  
  <pre><code>cfg =&gt;
              {
                  cfg.AllowNullDestinationValues = true;
                  cfg.AllowNullCollections = true;
                  cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
                  cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
                  cfg.RecognizeDestinationPrefixes("DTO_");
  
                  cfg.CreateMap&lt;Order, OrderDTO&gt;()
                      .ForMember(d=&gt;d.OrderLines,o=&gt;o.AllowNull())
                      .ForMember(d=&gt;d.OrderLines,o=&gt;o.MapFrom(s=&gt;s.OrderLines));
                  cfg.CreateMap&lt;OrderLine, OrderLineDTO&gt;();
              });
  </code></pre>
  
  <p>Now if I browse the URL by </p>
  
  <blockquote>
    <p><a href="http://localhost:34354/odata/Order" rel="nofollow noreferrer">http://localhost:34354/odata/Order</a>?$expand=OrderLines</p>
  </blockquote>
  
  <p>It is complaining with error below</p>
  
  <blockquote>
    <p>Cannot compare 'member 'OrderLines' of type 'c4codata.OrderDTO''. Only primitive types, enumeration types and entity types are supported.</p>
  </blockquote>
  
  <p>What did I did wrong? This has struggled me for days, please help!!</p>
  
  <p>I've uploaded the repo to <a href="https://github.com/ninithepug/odata" rel="nofollow noreferrer">https://github.com/ninithepug/odata</a></p>