Linq2Entities尝试将表达式转换为SQL.自定义C#代码就像VerifyHashedPassword
无法翻译.
作为解决方法,首先执行Linq查询,然后在内存中应用自定义代码.
var matchingUsers = db.AspNetUsers.Single(a => a.UserName).ToArray(); // enumerating the query will execute it var v = matchingUsers.SingleOrDefault(a => VerifyHashedPassword(Convert.FromBase64String(a.PasswordHash), user.PasswordHash) == true);