AutoMapper ProjectTo 与 Mapster ProjectToType
ProjectTo
return await _testQueryRepository .GetAll .OrderBy(p => p.CreateDate) .Take(20) .ProjectTo<T>() .ToListAsync();
在配置映射时使用了字符串连接:
conf.CreateMap<Post, PostDto>() .ForMember(dto => dto.Url, opt => opt.MapFrom(p => "https://www.cnblogs.com/" + p.Site.href + "/"));
ProjectToType
return await _testQueryRepository .GetAll .OrderBy(p => p.CreateDate) .Take(20) .ProjectToType<T>() .ToListAsync();
在配置映射时使用了字符串连接:
TypeAdapterConfig<Post, PostDto>.ForType() .Map(dest => dest.Url, src => "https://www.cnblogs.com/" + src.Site.href + "/");