SQL Generation

When you write a provider for the Entity Framework, you must translate Entity Framework command trees into SQL that a specific database can understand, such as Transact-SQL for SQL Server or PL/SQL for Oracle. In this section, you will learn how to develop a SQL generation component (for SELECT queries) for an Entity Framework provider. For information about insert, update, and delete queries, seeĀ Modification SQL Generation.

To understand this section, you should be familiar with the Entity Framework and the ADO.NET Provider Model. You should also understand command trees and DbExpression.

The Role of the SQL Generation Module

The SQL generation module of an Entity Framework provider translates a given query command tree into a single SQL SELECT statement that targets a SQL:1999-compliant database. The generated SQL should have as few nested queries as possible. The SQL generation module should not simplify the output query command tree. The Entity Framework will do this, for example by eliminating joins and collapsing consecutive filter nodes.

The DBProviderServices class is the starting point for accessing the SQL generation layer to convert command trees into DbCommands.

In This Section

The Shape of the Command Trees

Generating SQL from Command Trees - Best Practices

SQL Generation in the Sample Provider

See Also

Concepts

Writing an Entity Framework Data Provider