Note: pseduo code and fake-thought-up-on-the-spot classes/properties … to protect the innocent
I’m trying to retrieve the Person instance, where the person has a particular name … as an IQueryable result.
Given the following code…
public class Person
{
public ICollection<PersonDetails> PersonDetails { get; set; }
}
public class PersonDetails
{
public string Name { get; set; }
}
how can I retrieve a Person, who has the name ‘Fred’ ?
I was trying (which failed) ….
public static IQueryable<Person> WithName(this IQueryable<Person> value,
string name)
{
return value.Where(x => x.PersonDetails.Where(y => y.Name == name));
}
.. and that doesn’t compile.
Any clues, peeps?
Try
Anyinstead of the secondWhere: