AutoMapper: setup member name matching convention

Posted by epitka on Stack Overflow See other posts from Stack Overflow or by epitka
Published on 2010-02-12T20:48:27Z Indexed on 2010/05/05 18:28 UTC
Read the original article Hit count: 197

Filed under:
|

I tried setting up a member name mapping convention so that the source members ending with a "Id" are mapped to destination members without Id. For example

UserId -> User

How does one do this? I tried using SourceMemberNameTransformer without success. Also tried using RecognizePostfixes().

    this.SourceMemberNameTransformer = s =>
                                      {     
                                          return s.Replace("Id", string.Empty);
                                      };

© Stack Overflow or respective owner

Related posts about automapper

Related posts about c#