In-Memory Data

Starting from the same in-memory collection of products, we want to get rid of our imperative code that obfuscated the meaning of our query before. Here, we’re using the LINQ to Objects implementation, which implements the query pattern for objects that implement IEnumerable<T>. Given the following data source, we want to express a query that will give us back only the products with a price less than $25:

var products = new List<Product> {    new Product { Name = "Chai", Price = 18.00m },    new Product { Name = "Chang", Price = 19.00m },    new Product { Name = "Aniseed Syrup", Price = 10.00m },    new Product { Name = "Chef Anton's Cajun Seasoning", Price = 22.00m },    new Product { Name = "Chef ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.