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.
LINQ to Entities
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
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.
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.
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.