Where operator
The LINQ operator that keeps only the items for which a predicate returns true.
In more detail
On an IQueryable<T> it becomes a SQL WHERE clause; on an IEnumerable<T> it runs in memory. Either way it runs nothing until the query is enumerated.
Example
all.Where(p => p.Price < 20m)Related terms
- LINQ — Language Integrated Query: a set of C# operators such as Where, Select and OrderBy for filtering, shaping and combining sequences of data.
- predicate — A function or condition that answers true or false about a value, used to filter, search or check data.
- WHERE clause — The part of a query that keeps only the rows for which a condition is true.
Taught in
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- Querying, Change Tracking, and Saving Data — Modern .NET Core, C# & Enterprise Microservices