Skip to content

Instantly share code, notes, and snippets.

@komainu85
Created July 17, 2015 14:51
Show Gist options
  • Save komainu85/4079e0a0a34172dc8888 to your computer and use it in GitHub Desktop.
Save komainu85/4079e0a0a34172dc8888 to your computer and use it in GitHub Desktop.
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