我想在我的ASP.NET-MVC 3 + SQL Server 2008應用程序中顯示當前自動化用戶表中的所有記錄。但我有一些問題:LINQ不想在ASP.NET MVC中顯示
該代碼使用LINQ要求工作良好:
public ActionResult Index(todo obj)
{
string u = User.Identity.Name;
var th = (from tt in _db.todo select tt);
return View(th);
}
但是這個代碼不工作:
public ActionResult Index(todo obj)
{
string u = User.Identity.Name;
var th = (from tt in _db.todo where obj.login == u select tt);
return View(th);
}
這個代碼工作良好
if (u == obj.login) { ViewBag.res = "ok"; } else { ViewBag.res = "fail"; }
我做錯了,請幫助我。
哦不, 這是史詩般的失敗! 非常感謝你,thanx :) – user 2012-04-05 16:30:16