自动映射:将列表映射到ICollection

时间:2014-01-02 20:31:08

标签: 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:
DeploymentOrder.ItemList.ItemList.ItemList0[0]

Source value:
System.Data.Entity.DynamicProxies.usr_OrderFulfillment_E409120B2301A726DF3596B7433A063CC823D334AC1786DA2C7D2A1870A42CE3

域对象(生成的实体框架)

 public string SOPNUMBE { get; set; }
 public string CustomerNumber { get; set; }
 public string ShipMethod { get; set; }
 public string ContactPerson { get; set; }
 public string ShiptToName { 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 Nullable<System.DateTime> DateComplete { get; set; }
 public string CompletedBy { get; set; }
 public System.DateTime DateCreated { get; set; }

 public virtual ICollection<usr_OrderFulfillment> 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; }
    }

我正在创建地图:

 Mapper.CreateMap<usr_OrderFulfilled, DeploymentOrder>().ForMember(x => x.ItemList, opt => opt.MapFrom(origin => origin.usr_OrderFulfillment));

我已经尝试将View Model中的ItemList属性更改为ICollection,但我仍然得到相同的错误。

0 个答案:

没有答案