Database query performance
We saw in Chapter 6, The .NET Collection, how IEnumerator
is different from IEnumerable
, and how IEnumerator
performs faster than IEnumerable
when iterating through an in-memory collection. Now, we will query a database and iterate through the resulting collection using various benchmarked techniques. To do so, we will follow these steps:
- Add a new class called
IEnumeratorVsIQueryable
. - You will be connecting to a SQL Server database and will have the information you need to keep secret. Your
secret.json
files do not get checked into version control. So, right-click on the project and select Manage User Secrets from the context menu. - A dialog will pop up informing you that additional packages are required. Click on Yes.
- Visual Studio will then open the
secrets.json
file in a new tab. This is where you will add your...