Web developer can modify the where clause in LINQ statement to filter the results and to include only those that match a specific condition. The next code shows how to find clients who have a last name that starts with a specific letter:

C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development: Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code, 4th Edition
ASP.NET Core 3 and Angular 9: Full stack web development with .NET Core 3.1 and Angular 9, 3rd Edition
C# in Depth, 4th Edition

 

var matches = from client in clients

where client.LastName.StartsWith(“P“)

select client;

 

Web developer can combine multiple conditional expressions with the and (&&) and or (||) operators, and he/she can use relational operators (such as <, <=, >, and >=) in conjunction with hard-coded values or other variables. For example, Web developer could create a query like this to filter out products greater than a certain price threshold:

 

var matches = from product in products

where product.UnitsInStock > 0 && product.UnitPrice > 75.00S

select product;