我有 linq 的问题,我有以下代码:
Models.Users user = null;
foreach (var item in db.Users)
{
if (item.username.Equals(username))
{
ausgabe = true;
user = item;
}
}
// linq, does not work
user = null;
var test = from u in db.Users
where u.username.Equals(username)
select u;
user = (Models.Users)test;
在运行时我得到一个错误,因为测试我 IQueryable,但如何进行这个对话?