When we think about querying databases, the first thing that pops to mind is usually some SQL query. Then other questions arise in regards to the database type, connection, query design, etc.
LINQ to Entities combined with Entity Framework allows the developers to skip a big portion of these questions and worries.
Entity Framework handles the database structure and connection while LINQ to Entities gives the possibility to write database queries in the same way as for any other data collection operation with LINQ.
In Entity Framework, the collections of entities are represented by the DbSet class which is derived from IQueriable. That means that we can use LINQ queries to query DbSet.
LINQ to Entities converts the LINQ queries to the command tree queries. Command tree is a query representation that the Entity Framework can understand.
Then the command tree queries get converted to the SQL queries and executed against the target database. The result-set is converted back to the list of appropriate entity objects.
The processes of creation and execution of LINQ to Entities queries takes five steps:
#c# #programming #linq