我正在尝试获取用户登录但收到此错误的结果:
“无法比较 'System.Linq.IQueryable`1' 类型的元素。仅支持原始类型、枚举类型和实体类型。”
这是我在索引操作中应用的查询:
var viewModel = new PointsViewModel();
viewModel.Point = db.Point.ToList();
viewModel.Redeem = db.Redeem.ToList();
TempData["UserPoints"] = null;
var usrname = (from a in db.Instructors
where a.Email == User.Identity.Name
select new { a.PersonID });
if (usrname.Count().Equals(0))
{
TempData["UserPoints"] = "You have not earn any points yet.";
return View();
}
viewModel.instructor = db.Instructors
.Where(i => i.PersonID.Equals(usrname))// if I directly insert id here then it works properly but I don't want direct inserts
.Single();
PopulateAssignedPointData(viewModel.instructor);
return View(viewModel);
请帮我解决这个问题...我无法在谷歌上找到任何解决方案