2
How do I convert/map a list from one entity to another reference explicitly. Here’s an example I was able to perform with an entity:
public static explicit operator UserResponse(Entities.User entity)
{
return new UserResponse()
{
Id = entity.Id,
Role = entity.Role,
Email = entity.Email,
UserStatus = entity.UserStatus
};
}
So I can convert explicitly within a business rule:
(UserResponse) await _userRepository.Create((User) user);
I would like to do this for a list, rather than using the method below:
public static List<UserResponse> FromIList<User>(IList<Entities.User> entity)
{
return entity.Select(item => new UserResponse()
{
Id = item.Id,
Role = item.Role,
Email = item.Email,
UserStatus = item.UserStatus
}).ToList();
}
}
I used the code created by you in the example of my answer, I hope it’s not a problem.
– Jéf Bueno
@LINQ It’s an honor for me! kkk :)
– George Wurthmann