I'm not sure i've understood you correctly, but...
Seems, you want to filter
List<RoleView>
by passing list of
id's
to find. For such of requirement, you can use
Where
+
Any
methods. Take a look at example:
void Main()
{
List<Role> rules = new List<Role>();
for (int i=1; i<=10; i++)
rules.Add(new Role(i));
int[] rules2find = new int[]{1,5,9};
var filteredlist = rules
.Where(x=>rules2find.Any(y=>x.RoleID ==y))
.ToList();
foreach(Role r in filteredlist)
{
Console.WriteLine(r.RoleID);
}
}
public class Role
{
private int id = 0;
public Role(int _id)
{
id = _id;
}
public int RoleID
{
get {return id;}
set {id = value;}
}
}
For further details, please see:
Enumerable.Where(TSource) Method (IEnumerable(TSource), Func(TSource, Boolean)) (System.Linq)[
^]
Enumerable.Any(TSource) Method (IEnumerable(TSource), Func(TSource, Boolean)) (System.Linq)[
^]