例如:
public static TDto Map(this IMapper mapper, T entity)
where T : BaseEntity
where TDto: BaseDto
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap();
});
var map = config.CreateMapper();
return map.Map(entity);
}
例如:
public static IQueryable ProjectToNonGeneric(this IQueryable source, IMapper mapper)
where TDto : class
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap();
});
var map = config.CreateMapper();
return source.ProjectTo(m => map.Map(m));
}