concept where clause in category .net

appears as: where clause
C# in Depth

This is an excerpt from Manning's book C# in Depth.

This is effectively a LINQ query without using the System.Linq namespace. It would work perfectly well in .NET 2.0 if you declared the appropriate Func delegate and [ExtensionAttribute]. You could even use that implementation for the where clause in a query expression (while still targeting .NET 2.0), as you’ll see in the next chapter—but let’s not get ahead of ourselves.

Listing 11.3 illustrates how the compiler translation works: it provides a dummy implementation of both Select and Where, with Select as a normal instance method and Where as an extension method. Our original simple query expression only contained a select clause, but this one includes a where clause to show both kinds of methods in use. This is a full listing rather than a snippet as extension methods can only be declared in top-level static classes.

11.3.1. Filtering using a where clause

It’s remarkably easy to understand the where clause. The syntax is just