I'm wondering if there is anything I can do to get this working as expected. This works fine in my code:
var roles = _securityContext.Set<Role>();
var roleList = new List<RoleDto>();
foreach (var role in roles)
{
roleList.Add(Mapper.Map<Role, RoleDto>(role));
}
return roleList;
But changing this to:
var roles = _securityContext.Set<Role>();
return roles.Select(role => Mapper.Map<Role, RoleDto>(role)).ToList();
Results in an error I've not seen before:
"LINQ to Entities does not recognize the method 'Security.Dto.RoleDto MapRole,RoleDto' method, and this method cannot be translated into a store expression"
I'm not sure if I can even do anything about this'problem' ... arguably the method that works is more readable anyway ...