Filtering
Method | Description | SQL equivalents |
|---|---|---|
| Returns a subset of elements that satisfy a given condition | |
| Returns the first |
|
| Ignores the first | |
| Emits elements from the input sequence until the predicate is true | Exception thrown |
| Ignores elements from the input sequence until the predicate is true, and then emits the rest | Exception thrown |
| Returns a collection that excludes duplicates | |
Note
The “SQL equivalents” column in the reference tables does not
necessarily correspond to what an IQueryable implementation such as LINQ to
SQL will produce. Rather, it indicates what you’d typically use to do
the same job if you were writing the SQL query yourself. Where there
is no simple translation, the column is left blank. Where there is no
translation at all, the column reads “Exception thrown.”
Enumerable implementation
code, when shown, excludes checking for null arguments, and indexing
predicates.
With each of the filtering methods, you always end up with either the same number or fewer elements than you started with. You can never get more! The elements are also identical when they come out; they are not transformed in any way.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access