agileobjects / AgileMapper

A zero-configuration, highly-configurable, unopinionated object mapper with viewable execution plans. Flattens, unflattens, deep clones, merges, updates and projects queries. .NET 3.5+ and .NET Standard 1.0+.
MIT License
460 stars 27 forks source link

Correct usage of ThrowIfAnyMappingPlanIsIncomplete? #224

Closed C-Wal closed 2 years ago

C-Wal commented 2 years ago

If I use _mapper.WhenMapping.ThrowIfAnyMappingPlanIsIncomplete() then I get exceptions when my mapping runs but if I do not add _mapper.WhenMapping.ThrowIfAnyMappingPlanIsIncomplete() then the mapping works fine and returns my mapped object. Is this expected? I'm using 1.8.1.

SteveWilkes commented 2 years ago

Hello!

ThrowIfAnyMappingPlanIsIncomplete will throw an exception if the plan created for mapping two types:

A mapping plan is created either the first time any two types are mapped, or when you call one of the Mapper.GetPlansFor<TSource>().To<TTarget>() methods.

Hope that makes sense?

Steve

C-Wal commented 2 years ago

Yes thanks for that explanation.

FYI I do have a situation where the mapping works but adding ThrowIfAnyMappingPlanIsIncomplete causes it to throws a 'Couldn't find a value for that key' exception but I don't have a repro yet.