From the course: .NET Essentials: LINQ for Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Projection, get fewer columns

Projection, get fewer columns - .NET Tutorial

From the course: .NET Essentials: LINQ for Databases

Start my 1-month free trial

Projection, get fewer columns

- In this chapter, we'll look at query techniques and interesting tools for querying the data. We'll start by looking at ways to reduce the amount of data return from a database query. There are several ways to handle this in LINQ. What I'm looking at in this video is the where extension method and the select extension method which are also the where and select clauses when we're using the query expression. The where clause is used to filter the number of rows that are returned and the select clause, also known as projection, is used to filter the number of columns returned. So what I do in starting here in this code, is I count the number of rows in the customers table, and I see there are 91 rows. Then I use a where clause here in my query expression to filter the list to only rows where the city name starts with the capital letter, uppercase S. When output that information, I see there's 12 items, so we did…

Contents