0
以下は、私が説明しているベアボーンクラスのセットアップです。Automapper:同じ名前のクラスとプロパティがマッピングされていない
public class List
{
public int Id {get;set;}
public RecipientCount RecipientCount {get;set;}
public RecipientCount SomeOtherName {get;set;}
}
public class RecipientCount
{
public int Total {get;set;}
public int Active {get;set;}
}
public class ListDto
{
public int id {get;set;}
public RecipientCountDto recipientCount {get;set;}
public RecipientCountDto someOtherName {get;set;}
}
public class RecipientCountDto
{
public int total {get;set;}
public int active {get;set;}
}
public class AutoMapperConfiguration
{
public void Init(AutoMapper.IConfiguration config)
{
config.CreateMap<RecipientCount,RecipientCountDto>();
}
}
私はこれを使用しようとすると、それはスロー:
The following property on Reachmail.Domain.Component.RecipientCountDto cannot
be mapped:
recipientCount
Add a custom mapping expression, ignore, add a custom resolver, or modify the
destination type Reachmail.Domain.Component.RecipientCount.
Context:
Mapping to property recipientCount of type Reachmail.Domain.Component.RecipientCountDto
from source type Reachmail.Domain.Component.RecipientCount
Mapping to type Reachmail.Web.UI.Controllers.ListDto from source type
Reachmail.Domain.Contacts.Lists.List
Exception of type 'AutoMapper.AutoMapperConfigurationException' was thrown.
しかし、私はRecipientProviderDto.recipientProvider削除した場合、それは正常に動作します。クラス名とプロパティが同じで問題を引き起こしているという事実を信じるようになります。それを修正する方法やそのバグについての洞察はありますか?