Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ where in List [duplicate]

i have list of projects iD

IEnumerable projects

That contains four numbers ,let's say 2,5,6,9

and this is my AllProjects

 IEnumerable<Project> AllProjects = await ctx.Projects.Where(x => x.ClientID == clientid).Where(y => y.Released == true).ToListAsync();

i want to filter my AllProjects with project id 2,5,6,9

should be some thing like ...

 AllProjects = AllProjects.Where(x=>x.ProjectID == ????)

Thanks

like image 245
Brad Kiani Avatar asked Dec 15 '22 18:12

Brad Kiani


1 Answers

AllProjects = AllProjects.Where(x=>projects.Contains(x.ProjectID))

You just need to check if the projects list contains the id you are looking for

like image 176
Sayse Avatar answered Dec 25 '22 20:12

Sayse