我將相當多的WCF數據合同映射到實體框架類。更自動的方式來使用自動映射器映射到實體框架對象
對於每類我必須做這樣的事情:
Mapper.CreateMap<MyContractClass, MyDalClass>()
.ForMember(x => x.EntityKey, opt => opt.Ignore())
.ForMember(x => x.SomeAssociation, opt => opt.Ignore())
.ForMember(x => x.SomeAssociationReference, opt=> opt.Ignore())
// Repeat
// the
// last
// /two
// lines
// for
// every
// single
// association
// (Some classes have a lot of associations)
;
是否有更簡單的方法?有什麼辦法可以排除EntityFramework提供的所有額外內容?
或者這是否只需要手工完成?
注意:我已經廣泛評估了POCO模板,但它不適用於我的場景。請不要只推薦使用Automapper。