public ActionResult Index()
{
var user = db.UserProfiles.FirstOrDefault(x => x.UserId == WebSecurity.CurrentUserId);
var allCategories = db.ProfitCategories
.Where(x => x.IdUser.UserId==user)
我希望我的索引视图只显示当前用户写入的记录。我从这里得到当前的用户 ID
var user = db.UserProfiles.FirstOrDefault(x => x.UserId == WebSecurity.CurrentUserId);
并且 x.IdUser.UserId
是从db.ProfitCategories
to的外键db.UserProfiles
。编译时出现以下错误:无法应用运算符==
类型 int
和 Models.UserProfiles
.