c# - Retrieve a list of items where an item exists in one of the items lists -


please excuse confusing title. have model (project) contains list of items (users).

i retrieve of projects, current user member of user list project.

i've tried:

list<project> _memberprojects =                     _db.projects.where(p =>                          p.users.contains(_user)                     ).tolist(); 

this results in following error:

unable create constant value of type 'nimble.models.useraccount'. primitive types or enumeration types supported in context. 

user model:

public class useraccount {     public int userid { get; set; }     public string username { get; set; }     public string password { get; set; }     public string name { get; set; }     public string surname { get; set; }     public string email { get; set; }     public icollection<project> projects{....} } 

project model

public class project {     public int projectid { get; set; }     public datetime createddate { get; set; }     public string projectname { get; set; }             public string owner { get; set; }            public icollection<useraccount> users{...}     public icollection<projectgroup> groups{...} } 

haven't tried this, might work:

list<project> _memberprojects =                 _db.projects.where(p =>                      p.users.any(u => u.userid == _user.userid )                 ).tolist(); 

Comments

Popular posts from this blog

php - Dynamic url re-writing using htaccess -

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -