AutoMapper を使用して WCF サービスのデータ コントラクト オブジェクトにマップする必要があるビジネス エンティティ オブジェクトがありますが、'MemberDataList' でエラーが発生します。データ エンティティ クラス 'Member' の同じバージョンを、マップに使用したデータ アクセス レイヤーから持っています。ビジネスオブジェクトクラスとその動作は正常ですが、なぜこれが問題になったのかわかりません
ソース クラス
public class Member
{
public int MemberID { get; set; }
public string Title { get; set; }
public string Surname { get; set; }
public string Forename { get; set; }
public string MiddleName { get; set; }
public string PrevSurname { get; set; }
public System.DateTime DOB { get; set; }
public string Sex { get; set; }
public Address Address { get; set; }
public ContactDetail ContactDetail { get; set; }
public Membership Membership { get; set; }
}
宛先クラス
[DataContract]
public class MemberData : IIdentifiableEntity
{
[DataMember]
public int MemberID { get; set; }
[DataMember]
public string Title { get; set; }
[DataMember]
public string Surname { get; set; }
[DataMember]
public string Forename { get; set; }
[DataMember]
public string MiddleName { get; set; }
[DataMember]
public string PrevSurname { get; set; }
[DataMember]
public System.DateTime DOB { get; set; }
[DataMember]
public string Sex { get; set; }
[DataMember]
public AddressData Address { get; set; }
[DataMember]
public ContactDetailData ContactDetail { get; set; }
[DataMember]
public MembershipData Membership { get; set; }
int IIdentifiableEntity.EntityId
{
get { return MemberID; }
set { MemberID = value; }
}
}
マッピング クラス
public IList<MemberData> GetAllMember()
{
IList<MemberData> MemberDataList = null;
IList<Member> memberList = _MembershipCoreServices.GetAllMember();
if (memberList != null)
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<Member, MemberData>();
});
IMapper mapper = config.CreateMapper();
MemberDataList = mapper.Map<IList<MemberData>>(memberList).ToList();
}
return MemberDataList;
}
エラー
AutoMapper.AutoMapperMappingException was unhandled
HResult=-2146233088
Message=Missing type map configuration or unsupported mapping.
Mapping types:
Address -> AddressData
App.Core.Entities.Address -> App.Services.Contracts.AddressData
Destination path:
IList`1[0].Address0[0].Address0[0]
Source value:
(null)
Source=AutoMapper
StackTrace:
at App.Services.Managers.MembershipManager.GetAllMember() in C:\My Work\Credit Union Application\CreditSolutionApp\App.Services.Managers\Membership\MembershipManager.cs:line 35
at TestingApp.Program.Main(String[] args) in C:\My Work\Credit Union Application\CreditSolutionApp\TestingApp\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
内部例外: