15
I have this two classes:
public class Item
{
public int Id{get;set;}
public List<Test> TestList{get;set;}
}
public class Test
{
public int Id{get;set;}
public Item Item{get;set;}
public byte State{get;set;}
}
Item Class Data:
Id
1
2
3
And Test Class Data:
Item State
1 1
1 2
1 3
2 1
2 4
3 2
Now i need to write a query that select the Items from my class that just have state of 1 and 2.For example for the sample above it should returns row with Item=3. i wrote this query:
var stateList=new List<byte>(){1,2};
Items.Where(x => x.TestList.Select(c => c.State).Any(s => stateList.Contains(s)));
but it returns Item=1 either.Any Idea?