試圖根據viewModel上的特定字段跳過屬性映射。有什麼辦法來訪問ForAllMembers源對象 - >工況法ForAllMembers方法中的訪問源對象
Mapper.CreateMap<AViewModel, AEntity>()
.IgnoreMembers(ignoreMembers)
.ForAllMembers(o => {
o.Condition(ctx => {
//Need to access AViewModel instance here
return "Id" == ctx.MemberName;
});
});
我認爲這明確回答了這個問題,但對付你是在對象層次結構中的不確定性會讓我想避免做這種方式。 – 2012-04-04 11:58:10
感謝它的工作 – user1312702 2012-04-04 12:01:50