我有以下代码
return (_entities.Users.Select(profile => new ProfileUserListItemDto
{
Email = profile.Email,
FirstName = profile.FirstName,
Id = profile.Id,
LastName = profile.LastName,
Role = DtoEntityLookups.EntityRoleToDtoRole(profile.Role),
TimeZone = profile.TimeZone
})).ToList();
public static RoleTypeEnum EntityRoleToDtoRole(Role role)
{
if (role == null)
throw new NoNullAllowedException("Null role supplied to EntityRoleToDtoRole method");
if (role.Id.ToString() == RolesGuid.AdministratorGuid)
return RoleTypeEnum.Administrator;
if (role.Id.ToString() == RolesGuid.ClientGuid)
return RoleTypeEnum.Client;
throw new InvalidDataException("Unknown role supplied");
}
调用时出现以下错误
LINQ to Entities 无法识别方法 RoleTypeEnum EntityRoleToDtoRole(User.Entities.Entities.Role)' 方法,并且此方法无法转换为存储表达式。
如何将EntityRoleToDtoRole
Entity Framework 查询转换为可调用的?