Asp.net mvc 自动映射:将列表映射到ICollection
尝试将域对象映射到模型时出现此错误:Asp.net mvc 自动映射:将列表映射到ICollection,asp.net-mvc,asp.net-mvc-4,automapper,Asp.net Mvc,Asp.net Mvc 4,Automapper,尝试将域对象映射到模型时出现此错误: Missing type map configuration or unsupported mapping. Mapping types: usr_OrderFulfillment -> ItemInfo TPGCommon.Data.EntityFramework.usr_OrderFulfillment -> TPGEnterprise.TpgInternalSite.Models.ItemInfo Destination path: D
Missing type map configuration or unsupported mapping.
Mapping types:
usr_OrderFulfillment -> ItemInfo
TPGCommon.Data.EntityFramework.usr_OrderFulfillment -> TPGEnterprise.TpgInternalSite.Models.ItemInfo
Destination path:
DeploymentOrder.ItemList.ItemList.ItemList0[0]
Source value:
System.Data.Entity.DynamicProxies.usr_OrderFulfillment_E409120B2301A726DF3596B7433A063CC823D334AC1786DA2C7D2A1870A42CE3
域对象(生成实体框架)
公共字符串sopnumber{get;set;}
公共字符串CustomerNumber{get;set;}
公共字符串方法{get;set;}
公共字符串ContactPerson{get;set;}
公共字符串ShiptToName{get;set;}
公共字符串地址1{get;set;}
公共字符串地址2{get;set;}
公共字符串地址3{get;set;}
公共字符串City{get;set;}
公共字符串状态{get;set;}
公共字符串Zipcode{get;set;}
公共bool OrderComplete{get;set;}
公共可为空的日期完成{get;set;}
由{get;set;}完成的公共字符串
public System.DateTime DateCreated{get;set;}
公共虚拟ICollection usr_OrderFulfillment{get;set;}
查看模型
public class DeploymentOrder
{
public string OrderNumber { get; set; }
public string ItemNumber { get; set; }
public string CustomerNumber { get; set; }
public string ShipMethod { get; set; }
public string ContactPerson { get; set; }
public string ShipToName { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3{ get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
public bool OrderComplete { get; set; }
public DateTime DateComplete { get; set; }
public string CompletedBy { get; set; }
public bool HasPrintPlate { get; set; }
public List<ItemInfo> ItemList { get; set; }
public List<usp_SelectPlateInfo_Result> Plates { get; set; }
}
public class ItemInfo
{
public int LNITMSEQ { get; set; }
public int CMPNTSEQ { get; set; }
public bool IsFulfilled { get; set; }
public DateTime DateFulfilled { get; set; }
public string FulfilledBy { get; set; }
public string ItemNumber { get; set; }
public short ItemType { get; set; }
public decimal TotalQuantity { get; set; }
public string Uofm { get; set; }
}
公共类部署器
{
公共字符串OrderNumber{get;set;}
公共字符串ItemNumber{get;set;}
公共字符串CustomerNumber{get;set;}
公共字符串方法{get;set;}
公共字符串ContactPerson{get;set;}
公共字符串ShipToName{get;set;}
公共字符串地址1{get;set;}
公共字符串地址2{get;set;}
公共字符串地址3{get;set;}
公共字符串City{get;set;}
公共字符串状态{get;set;}
公共字符串ZipCode{get;set;}
公共bool OrderComplete{get;set;}
公共日期时间日期完成{get;set;}
由{get;set;}完成的公共字符串
公共bool有印刷版{get;set;}
公共列表项列表{get;set;}
公共列表板{get;set;}
}
公共类ItemInfo
{
公共int LNITMSEQ{get;set;}
public int CMPNTSEQ{get;set;}
公共布尔值已实现{get;set;}
public DateTime datecompleted{get;set;}
由{get;set;}实现的公共字符串
公共字符串ItemNumber{get;set;}
公共短项目类型{get;set;}
公共十进制总数{get;set;}
公共字符串Uofm{get;set;}
}
我正在这样创建地图:
Mapper.CreateMap<usr_OrderFulfilled, DeploymentOrder>().ForMember(x => x.ItemList, opt => opt.MapFrom(origin => origin.usr_OrderFulfillment));
Mapper.CreateMap().ForMember(x=>x.ItemList,opt=>opt.MapFrom(origin=>origin.usr_OrderFulfillment));
我已尝试将视图模型中的ItemList属性更改为ICollection,但仍然出现相同的错误
Mapper.CreateMap<usr_OrderFulfilled, DeploymentOrder>().ForMember(x => x.ItemList, opt => opt.MapFrom(origin => origin.usr_OrderFulfillment));