Querying EF Core models
Now that we have a model that maps to the Northwind database and two of its tables, we can write some simple LINQ queries to fetch data. You will learn much more about writing LINQ queries in Chapter 11, Querying and Manipulating Data Using LINQ.For now, just write the code and view the results:
- In the
WorkingWithEFCore
project, add a new class file namedProgram.Helpers.cs
. - In
Program.Helpers.cs
, add a partialProgram
class with aSectionTitle
method, as shown in the following code:
partial class Program
{
private static void ConfigureConsole(string culture = "en-US",
bool useComputerCulture = false)
{
// To enable Unicode characters like Euro symbol in the console.
OutputEncoding = System.Text.Encoding.UTF8;
if (!useComputerCulture)
{
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(culture);
}
WriteLine($"CurrentCulture: {CultureInfo.CurrentCulture.DisplayName}");
}
private static void WriteLineInColor...