-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for common table expressions (aka WITH) via special LINQ operator #26486
Comments
Note: all major databases support prefixing UPDATE/DELETE with CTEs (see #795 for bulk updates). |
Note: all databases - except SQL Server - support embedding CTEs within arbitrary subqueries inside the query; SELECT * FROM (WITH t AS (SELECT 1) SELECT * FROM t) AS foo; This effectively makes CTEs an optional prefix of SelectExpression. In addition, SQL Server (but not other databases) requires that column names be explicitly specified when they're not named within the subquery: WITH t AS (SELECT 1 AS q) SELECT * FROM t; -- Column name bubbles out of the subquery
WITH t (q) AS (SELECT 1) SELECT * FROM t; -- Column explicitly specified as part of the CTE syntax
WITH t AS (SELECT 1) SELECT * FROM t; -- Fails in SQL Server, works elsewhere (with unknown column name) |
We could have a special queryable-returning function which we'd translate into a TableExpressionBase:
... becomes:
Do recursive CTEs as well.
Note: CTEs are also valid with
WITH ... INSERT ... INTO
,WITH ... DELETE
,WITH ... UPDATE
.See also #29918 (embedded IQueryables to common table expressions)
Community implementations
The text was updated successfully, but these errors were encountered: