LINQ to Entities

Entity Framework

Eager Loading in Entity Framework

Eager loading is a process where related entities are loaded along with the target entity. Eager loading does this by using the Include method. Entity Framework creates a join query, when it sees the Include method, thus bringing all the records in one single query.

Entity Framework

Entity Framework Logging Database Queries

Entity Framework starting from Version 6.0 allows us to log the commands & queries sent to the database. The Logging is done by using the DbContext.Database.Log property, which can be set to a delegate for any method that takes a string. All the actions performed by the Entity Framework is logged, which includes opening a connection, closing a connection, database initialization , Add, Edit, Insert & Select Queries, etc

Join Query In Entity Framework
Entity Framework

Join Query In Entity Framework

In this tutorial let us look into how to use Join Query in Entity Framework to load the data from two, three or more tables. The LINQ join operator allows us to join multiple tables on one or more columns (multiple columns). By default, they perform the inner join of the tables. We also learn how to perform left joins in Entity Framework by using the join operator & DefaultIfEmpty method.

Load Related Entities in Entity Framework
Entity Framework

Load Related Entities in Entity Framework

In this tutorial let us look into how to load the Related Entities in Entity Framework. We can load Related Entities either eager, lazy or explicit. Be default the EF loads the lazily. But you can instruct it load eagerly using the include method. Or else you can make use of projection queries to load the data. The other option is to load the data explicitly using the load method of the context. In the explicit method, we decide when to load the data.

Entity Framework

Projection Queries in Entity Framework

We use Projection queries in Entity Framework to create a query that selects from a set of entities in your model but returns results that are of a different type. This is also known as the query projection. We use Projection Queries to create a query that selects specific columns from a database table. Thy can return an anonymous type or a Concrete type.

Scroll to Top