<分区>
当尝试从模型在我的数据库上下文中执行 .Where() 时,我收到以下错误消息:
System.Data.Entity<RPSManagementSystem.Model.StoreUser> does not contain a definition for Where...
这在从 Controller 调用时有效。给了什么?
来自模型:
[NotMapped]
private List<StoreUser> _stores { get; set; }
[NotMapped]
public List<StoreUser> Stores
{
get
{
if (this._stores == null || this._stores.Count <= 0)
{
using (RPSEntities db = new RPSEntities())
{
this._stores = db.StoreUsers.Where(su => su.Username == this.Username);
}
}
return _stores;
}
}
为了确保我没有发疯,我将其粘贴到我的 Controller 中 - 它看起来可以正常工作。截图如下:
在模型中:
在 Controller 中: