Querying an EF Core model

Open the Program.cs file and import the following namespaces:

    using static System.Console; 
    using Packt.CS7; 
    using Microsoft.EntityFrameworkCore; 
    using System.Linq; 

In the Main method, add the following statements to:

  • Create an instance of the Northwind class that will manage the database
  • Create a query for all categories that includes their related products
  • Enumerates through the categories, outputting the name and number of products for each one
  • Prompt the user for a price for products
  • Create a query for products that cost more than the price by using LINQ
  • Loop through the results
 using(var db = new Northwind()) { WriteLine("List of categories and the number of products:"); IQueryable<Category> cats = db.Categories.Include(c ...

Get C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition now with the O’Reilly learning platform.

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