SQL Generation

.NET Framework (current version)

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 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 T:System.Data.Common.DBProviderServices class is the starting point for accessing the SQL generation layer to convert command trees into T:System.Data.Common.DbCommands.