次のコードがあります
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 クエリから呼び出し可能に変換するにはどうすればよいですか?