Search code examples
c#.netautomapperautomapper-2

automapper boolean properties to yes or no


For a mapping between TypeA and TypeB i would like all the boolean properties to be mapped to 'Yes' or 'No'. I don't want to override the <bool, string> mapping since i want that just for the mapping between TypeA and TypeB. And I would not like to use .ForMember for each TypeA's boolean property since they are a lot. Maybe there is a trick with ForAllMembers but I cannot make it works.


Solution

  • have you tried adding a mapper between Bool and String and registering it in the engine? It may be that simple, but I don't remember.

    you could also create a ValueConverter and then inform the mappings to use the converter. It's been awhile since i used AM, but this sounds about right.