任何想法可能導致錯誤「表達式映射方法尚不支持」。當試圖映射兩個對象?我無法在任何地方找到任何有關此錯誤的參考。Automapper錯誤:從不支持的方法映射表達式
EDITED ---
我有更多信息。我在我的DTO的屬性聲明爲:「從尚未支持的方法表達式映射」
public LookupItem RegionType { get; set; }
然而,當我調用映射,它產生的誤差。
但是,如果將屬性名稱「Type」中的字符串更改爲「Typeo」或「ASDF」之類的任何其他字符,則映射將成功。換句話說,如果將屬性名稱更改爲「RegionTypeo」。我在這裏違反任何約定規則嗎?在我的屬性名稱中包含字符串「Type」似乎有問題。
下面是生成的錯誤:
結果消息:
Test method Rep.Tests.PlanServiceTest.GetBuildings threw exception:
System.NotImplementedException: Expressions mapping from methods not supported yet.
Result StackTrace:
at AutoMapper.PropertyMap.ResolveExpression(Type currentType, Expression instanceParameter)
at AutoMapper.QueryableExtensions.Extensions.CreateMemberBindings(IMappingEngine mappingEngine, Type typeIn, TypeMap typeMap, Expression instanceParameter)
at AutoMapper.QueryableExtensions.Extensions.CreateMapExpression(IMappingEngine mappingEngine, Type typeIn, Type typeOut, Expression instanceParameter)
at AutoMapper.QueryableExtensions.Extensions.CreateMapExpression(IMappingEngine mappingEngine, Type typeIn, Type typeOut)
at AutoMapper.QueryableExtensions.Extensions.<>c__DisplayClass12.<CreateMapExpression>b__0(TypePair tp)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at AutoMapper.Internal.DictionaryFactoryOverride.ConcurrentDictionaryImpl2.GetOrAdd(TKey key, Func2 valueFactory)
at AutoMapper.QueryableExtensions.Extensions.CreateMapExpression[TSource,TDestination](IMappingEngine mappingEngine)
at AutoMapper.QueryableExtensions.ProjectionExpression1.ToTResult
at Rep.Services.PlanService.GetBuildings() in c:\Dev\REP\Rep\Services\PlanService.cs:line 369
at Rep.Tests.PlanServiceTest.GetBuildings() in c:\Dev\REP\Rep.Tests\PlanServiceTest.cs:line 50
您的代碼是否使用自定義成員解析器? – samy
我不明白你的意思是「屬性名稱中的字符串」。你還可以發佈DTO的CreateMap和Map調用嗎?澄清了 – samy
。包含字符串「類型」我屬性名稱似乎有問題。 – xgp