I have two classes:
public class firstClass
{
public int Id { get; set; }
public List<secondClass> Elements { get; set; }
}
public class secondClass
{
public int Id { get; set; }
public bool Is{ get; set; }
}
and using of their:
List<firstClass> list = allFirstClassFromDB.Include("Elements");
and then my list contain for example:
list[0] - {Id : 1, Elements : [0] { Id: 1, Is: true }, [1] { Id: 2, Is: true }, [2] { Id: 3, Is: false }
list[1] - {Id : 2, Elements : [0] { Id:4, Is: false }, [1] { Id: 5, Is: true }, [2] { Id: 6, Is: false }
list[2] - {Id : 3, Elements : [0] { Id:7, Is: false } }
So The result which I need is only this location which contain Elements which have Is prop set for true, sth like this:
list[0] - {Id : 1, Elements : [0] { Id: 1, Is: true }, [1] { Id: 2, Is: true } }
list[1] - {Id : 2, Elements : [0] { Id: 5, Is: true } }
It is possible in linq? Any help would be appreciated.