Created
July 10, 2018 11:30
-
-
Save brunomartinspro/4889edf69d58dea58101302c7c0f5eb7 to your computer and use it in GitHub Desktop.
Use AutoMapper to map properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using AutoMapper; | |
using BrunoMartinsPro.Data; | |
namespace BrunoMartinsPro.Config | |
{ | |
public class AutoMapperConfig | |
{ | |
/// <summary> | |
/// Initialize and configure AutoMapper Mappings | |
/// </summary> | |
public static void Initialize() | |
{ | |
Mapper.Initialize(config => | |
{ | |
config.CreateMap<PropertyModel, PropertyDto>() | |
.ForMember(destination => destination.UId, | |
origin => origin.MapFrom(property => property.Id)) | |
.ForMember(destination => destination.Date, | |
origin => origin.MapFrom(property => property.Date.ToString("yyyy-MM-dd hh:MM:ss"))); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment