有一个带有ef 6.1.3和automapper 6.1.1的Odata v3端点。
数据模型,
订单,一对多订单行
公共部门级订单 { [System.Diagnostics.CodeAnalysis.SuppressMessage(" Microsoft.Usage"," CA2214:DoNotCallOverridableMethodsInConstructors")] 公共秩序() { this.OrderLines = new HashSet(); }
public System.Guid OrderID { get; set; }
public string OrderPlacedBy { get; set; }
public Nullable<System.DateTime> PlacedTime { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<OrderLine> OrderLines { get; set; }
}
OrderLines
公共部分类OrderLine { public System.Guid OrderLineID {get;组; } public Nullable OrderID {get;组; } public Nullable Amount {get;组; }
public virtual Order Order { get; set; }
}
AutoMapper代码,
cfg =>
{
cfg.AllowNullDestinationValues = true;
cfg.AllowNullCollections = true;
cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
cfg.RecognizeDestinationPrefixes("DTO_");
cfg.CreateMap<Order, OrderDTO>()
.ForMember(d=>d.OrderLines,o=>o.AllowNull())
.ForMember(d=>d.OrderLines,o=>o.MapFrom(s=>s.OrderLines));
cfg.CreateMap<OrderLine, OrderLineDTO>();
});
现在,如果我按
浏览网址http://localhost:34354/odata/Order?$扩大= OrderLines
抱怨以下错误
无法比较&#39;会员&#39; OrderLines&#39;类型&#39; c4codata.OrderDTO&#39;&#39;。仅支持基本类型,枚举类型和实体类型。
我做错了什么?这已经困扰了我好几天了,请帮助!!