© Eric Vogel 2021
E. VogelBeginning Entity Framework Core 5https://doi.org/10.1007/978-1-4842-6882-7_12

12. Aggregations

Eric Vogel1  
(1)
Okemos, MI, USA
 

Entity Framework Core 5 includes several ways to aggregate your data. In this chapter, I will be covering count, min, max, average, sum, and group by. The group by clause is often used in conjunction with the aggregation operations. I will cover the simple operators first and then show how to use them with group by.

Unit Test Setup

We will be using unit tests to explore the various aggregation operators. Create a new NUnit class named AggregationTest in the DAL.Tests project. Initialize AppDbContext like in our other unit tests. Your code should now look like that in Listing 12-1.
using System;
using ...

Get Beginning Entity Framework Core 5: From Novice to Professional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.