Filtering Included Entities
Learn about filtered includes in EF Core and filtering and sorting data using Entity Framework Core by creating a complex query.
We'll cover the following...
We'll cover the following...
Filtering data using FilteredIncludes
method
EF Core 5 introduced filtered includes, which means we can specify a lambda expression in the Include
method call to filter which entities are returned in the results:
Step 1: In Program.Queries.cs
, define a FilteredIncludes
method, and add statements to do these tasks, as shown in the following code:
Create an instance of the
Northwind
class that will manage the database.Prompt the user to enter a minimum value for units in stock.
Create a query for categories with products with that minimum number of units in stock.
Enumerate through the ...