IEnumerable is an interface that exposes an enumerator. And an enumerator is used for iteration of a generic collection (or array). The class that implements IEnumerable is responsible for exposing the enumerator and providing its implementation.
IQueryable interface on the other hand, is intended to be implemented by data providers. IQueryable provides functionality to execute queries against a specific data source. And IQueryable is derived from IEnumerable.
Data access ORM (Object Relational Mapper) framework like Entity Framework Core exposes the implementation of IQueryable.
In this video, I will walk through creating a console application. And the application will use Entity Framework Core to access Employee table from a database. I will also add logging in the Entity Framework Core, to see actual queries fired against the database.
Once the code is executed, I will compare the difference in the query when we access the data using an IQueryable interface versus an IEnumerable interface.
21 июл 2024