Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automapper Adapter Pattern
public class Mapper : IMapper
{
public T Map<S, T>(S source)
{
AutoMapper.Mapper.CreateMap<S, T>();
T result = AutoMapper.Mapper.Map<S, T>(source);
return result;
}
public List<T> MapList<S, T>(List<S> source)
{
AutoMapper.Mapper.CreateMap<S, T>();
List<T> result = AutoMapper.Mapper.Map<List<S>, List<T>>(source);
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment