c# - Usage of Automapper when property names are different -
We are using Automapper from CodePlax and for me the Destination object has all the properties ending with 'field', that is Cityfield is the only city in the source object.
I can use the code below to get it, but all properties are stuck with just 'fields' and have 20 properties.
ForMember (dest => dest.cityField, opt => opt.MapFrom (origin = & gt; orig.City));
There is another way to ignore the field term during mapping and can map it without using .time (20 times)?
You can try to identify postfixes:
Mapper . Initialize (cfg = & gt; {cfg.RecognizePostfixes ("Field"); Cfg.CreateMap & lt; source, destination & gt; ();});
Accepting prefixes works locally in profiles, if it is only a set of maps that it applies to.
Comments
Post a Comment