Using LINQ how to select from a List within a List
public class Model
{
public string application { get; set; }
public List<Users> users { get; set; }
}
public class Users
{
public string name { get; set; }
public string surname { get; set; }
}
List<Model> list = new List<Model>();
I need to select list where application = “applicationame” and users where surname = “surname” into one list.
If you want to filter the models by
applicationnameand the remaining models bysurname:As you can see, it needs to create new models and user-lists, hence it is not the most efficient way.
If you instead don’t want to filter the list of users but filter the models by users with at least one user with a given username, use
Any: