When trying to execute a .Where() on my database context from a model, I am hit with this error message:
System.Data.Entity<RPSManagementSystem.Model.StoreUser> does not contain a definition for Where...
This works when calling it from a controller. What gives?
From the model:
[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;
}
}
Just to make sure I'm not crazy, I pasted this into my controller - where it looks to be working. Screenshots below:
in the model:
in the controller: