1

i have a list of objects(1) with a list of another objects(2) inside. i want to select some objects(1) from the first list with some king of a .where looking in the other list(2).

my classes are something like that:

class objects(1)
{
    public int Id { set; get;}
    List<Objects(2)> Objects(2) { set; get;}
}
class objects(2)
{
    public int Id { set; get;}
    DateTime? Date { set; get;}
}

so i want to select all Objects(1) where List Objects(2) { set; get;} all the values in the list has DateTime? Date != null.

0

1 Answer 1

1

Try this:

List<Object1> listOfObjects1 = ...;
List<Object1> items = listOfObjects1.Where(x => x.Objects2 != null && !x.Objects2.Any(y => !y.Date.HasValue)).ToList();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.