我(被迫)使用AutoMapper version 1.1.0.188。我有一個基類SchufaBaseFeature和派生類SchufaFeature。AutoMapper Include無法按預期工作?
public partial class SchufaFeature : SchufaBaseFeature
{//some code here}
爲什麼Include沒有按照我預期的那樣工作?
這就是我與AutoMapper(映射到數據庫)來完成:
//TODO include does not work as it should!
Mapper.CreateMap<SchufaBaseFeature, CFSCHUFAFEATURE>()
.ForMember(dest => dest.FEATUREWITHOUTBIRTHDATE, opt => opt.MapFrom(src => GetSpecified(EnumToBool(src.featureWithoutBirthdate), src.featureWithoutBirthdateSpecified)))
.ForMember(dest => dest.OWNFEATURE, opt => opt.MapFrom(src => GetSpecified(src.ownFeature, src.ownFeatureSpecified)))
.Include<SchufaFeature, CFSCHUFAFEATURE>()
;
Mapper.CreateMap<SchufaFeature, CFSCHUFAFEATURE>()
.ForMember(dest => dest.DATE, opt => opt.MapFrom(src => GetDate(src.date)))
.ForMember(dest => dest.AMOUNT, opt => opt.MapFrom(src => src.amount.amount))
.ForMember(dest => dest.AMOUNTCUR, opt => opt.MapFrom(src => src.amount.currency))
.ForMember(dest => dest.NUMBEROFINSTALLEMENTS, opt => opt.MapFrom(src => TryParseToInt(src.numberOfInstallments)))
.ForMember(dest => dest.INSTALLMENTTYPE, opt => opt.MapFrom(src => src.installmentType))
;
它是正確的映射FEATUREWITHOUTBIRTHDATE和OWNFEATURE,但包括不叫。當我運行調試器時,第二個CreateMap從不被調用。
我檢查了文檔here(AutoMapper Github繼承),我仍然不明白我在做什麼錯。可能是什麼問題?是我還是在這個版本的AutoMapper中有錯誤?
我會在幾天內檢查此問題... – Devid
我無法解決包含問題。即使玩命令也會得到同樣的結果。 – Devid