Monday 15 April 2013

.net - AutoMapper : Map a destination property to a different source property/type based on some logic -


I want to map a source object to a destination object which has some additional properties that are not directly equivalent to the source properties Consider the example below:

  class source {string ImageFilePath; } Class Destination {bool IsFileSelected; Bull ISFilif; }  

Mapping logic for IsFileGif:

  Destination Obj.Isfile Gif = Path. Get Extension (sourceObj.ImageFilePath) == ".gif"? right wrong;  

Mapping logic for IsFile selected:

  destination obz. File selected = string.isanoloretic (source_buzz.imagefilepath)? True False; Also, because my source is an IDataReader, I want to know how to map the fields / columns of the IDataReader object to my destination property.  

Do we have to get it using the inline code or for this we have to use value resellers?

Have you tried to use this Mapfrum method?

  Mapper.cctemap  

About IDataReader In, I think you should have a mapping between your classes (Source to Destination), not from IDataReader to Destination ...


No comments:

Post a Comment