Database query performance
In the previous section, we saw how IEnumerator
is different from and performs faster than IEnumerable
when iterating through an in-memory collection. Now, let's query a database and iterate through the resulting collection using various benchmarked techniques. To do so, we'll follow these steps:
- Add a new class called
IEnumeratorVsIQueryable
. - We will be connecting to a SQL Server database, and we will have information we need to keep secret. Our
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 box 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 user secrets.
...