I'm trying to get the count of all records in a table using a viewbag using and then display that in the view. For some reason this doesn't display anything.
我正在尝试使用viewbag来获取表中所有记录的计数,然后在视图中显示它。由于某种原因,这不会显示任何内容。
Controller
ViewBag.Users = db.Forum.Count();
View
@ViewBag.Users
1 个解决方案
#1
0
Try this
db.Forum.Select(g => g.id).Count();
db.Forum.Select(g => g.id).Count();
Replace g.id with your Forum Table Primary Key
用论坛表主键替换g.id.
#1
0
Try this
db.Forum.Select(g => g.id).Count();
db.Forum.Select(g => g.id).Count();
Replace g.id with your Forum Table Primary Key
用论坛表主键替换g.id.