下面这句代码哪里写错了
public ActionResult Index()
{
J_UserDataContext db=new J_UserDataContext ();
var q = (from u in db.J_User
orderby u.UserID descending
select u.UserNum).Take(1);
ViewData["num"] = q;
return View();
}
我要查第一条数据 结果为什么是 一条sql 语句而不是 结果呢? 帮忙 看下啊 谢谢了
------解决方案--------------------
var q = (from u in db.J_User
orderby u.UserID descending
select u.UserNum).Take(1).FirstOrDefault();
------解决方案--------------------哈哈 。。。囧~~~
LZ试试 这样:
public ActionResult Index()
{
J_UserDataContext db=new J_UserDataContext ();
var q = (from u in db.J_User
orderby u.UserID descending
select u.UserNum).FirstOrDefault();
ViewData["num"] = q;
return Content(q);
}
------解决方案--------------------