dre*_*att 18 c# asp.net entity-framework
当尝试从模型执行我的数据库上下文中的.Where()时,我遇到以下错误消息:
System.Data.Entity<RPSManagementSystem.Model.StoreUser> does not contain a definition for Where...
Run Code Online (Sandbox Code Playgroud)
这在从控制器调用时有效.是什么赋予了?
从模型:
[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;
}
}
Run Code Online (Sandbox Code Playgroud)
为了确保我没有疯狂,我将它粘贴到我的控制器中 - 它看起来在起作用.屏幕截图如下:
在模型中:

在控制器中:

| 归档时间: |
|
| 查看次数: |
12840 次 |
| 最近记录: |