Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use AutoMapper to map properties
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