O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required