lambda expression for exists within list

If listOfIds is a list, this will work, but, List.Contains() is a linear search, so this isn’t terribly efficient.

You’re better off storing the ids you want to look up into a container that is suited for searching, like Set.

List<int> listOfIds = new List(GetListOfIds());
lists.Where(r=>listOfIds.Contains(r.Id));

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)