自动映射器的新功能,所以我可以正确映射,这可行:
public class Client
{
public string Id { get; set; }
public string Name {get;set;}
public List<Transactions> Transactions{ get; set; }
}
Public class Transactions
{
public string Id { get; set; }
public string Name{get;set;}
}
AutoMapper.Mapper.Map(client, model);
但是现在我创建了一个更复杂的(视图)对象,如下所示:
public class Client
{
public string Id { get; set; }
public string Name {get;set;}
public List<Transactions> Transactions{ get; set; }
}
Public class Transactions
{
public string Id { get; set; }
public string Name{get;set;}
public List<TransactionType> TransactionType{ get; set; }
}
Public class TransactionType
{
public string Id { get; set; }
public string Name {get;set;}
}
AutoMapper.Mapper.Map(client, model);
所以问题是当我到达transactionTypes时,automapper没有映射这个。 我得到异常:AutoMapper缺少类型映射配置或不支持的映射。
Mapping types: TransactionType_2C08CB54C0C3A13374A03ADCB16E8CD7258880F22CB679B7C590FFAECDD6A517 -> List`1 System.Data.Entity.DynamicProxies.TransactionType2C08CB54C0C3A13374A03ADCB16E8CD7258880F22CB679B7C590FFAECDD6A517 -> System.Collections.Generic.List`1[[ViewModels.TransactionType, WebUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
我是如何解决这个问题的?