i have a question about automapper ProjectTo method, i have this DTO:
public class GetUsersResponse
{
public GetUsersResponse()
{
Users = new List<UserLite>();
}
public int Count { get; set; }
public List<UserLite> Users { get; set; }
}
public class UserLite
{
public string Email { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
}
i have an iqueryable result from EF with this code:
var users = await _userManager.Users.Where(user => user.Name.Contains(search)
|| user.Surname.Contains(search)
|| user.Email.Contains(search)
|| user.FiscalCode.Contains(search))
.PageBy(user => user.Email, page, pageSize, orderByAscending)
.ProjectTo<UserLite>(_mapper.ConfigurationProvider)
.ToListAsync();
My question is if is possible to use ProjectTo and set both count and Users, or i should use the classic map method from automapper? Currently my autommaper configuration is like this for projeaction:
public class UserMapperProfile : Profile
{
public UserMapperProfile()
{
CreateProjection<User, UserLite>(MemberList.Destination);
}
}
I hope I was clear. Thanks