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.
Use the Contains method for - .NET Tutorial
From the course: .NET Essentials: LINQ for Databases
Use the Contains method for
- [Instructor] Here's a scenario, when I want to use the results from one query as the criteria for a where clause in another query. So what I have here is my first query is from p in products where the unit price is greater than 90. And then I want to select out the product ID. So if it run just this query, I get three items in my results. These are the three product IDs that I want to use in my where clause. Now let's take a look at the orders details. That's what I'm going to query next, the order details. So if I look at what's available there, so I see that the order details has the order ID, product ID, unit price, quantity, and discount, and some navigation links. So I want to be able to query on this column, the product ID. So here's the solution I'm going to write my query, and then I can use the list class has a contains method that determines whether an item's contained in the list. So what I do here is…
Contents
-
-
-
-
-
-
-
(Locked)
Projection, get fewer columns2m 19s
-
(Locked)
Paging with Take and Skip1m 49s
-
(Locked)
Use Find for faster search by key1m 58s
-
(Locked)
Use EF navigation properties instead of joins3m 4s
-
(Locked)
Use the Contains method for1m 36s
-
(Locked)
Organize query results into groups with GroupBy3m 7s
-
(Locked)
Flatten child collections with SelectMany1m 36s
-
(Locked)
Find data within a date range1m 20s
-
(Locked)
-