Class CteQuery
Fluent scope that collects the CTE declarations of a query. With(string, QueryCommand) /
WithRecursive(string, QueryCommand, int?) add a definition and return a new scope (declarations are immutable),
and From(string) starts a query whose from is one of the declared CTEs while
carrying every declaration into the resulting command.
public sealed class CteQuery
- Inheritance
-
CteQuery
- Inherited Members
- Extension Methods
Properties
Ctes
Declarations collected so far, in declaration order.
public IReadOnlyList<CteDefinition> Ctes { get; }
Property Value
Methods
From(CteDefinition)
Starts a query whose source is cte.
public EntityBuilder<TableAlias> From(CteDefinition cte)
Parameters
cteCteDefinition
Returns
From(string)
Starts a query whose source is the CTE declared as cteName.
public EntityBuilder<TableAlias> From(string cteName)
Parameters
cteNamestring
Returns
With(string, QueryCommand)
Declares a non-recursive common table expression.
public CteQuery With(string name, QueryCommand query)
Parameters
namestringqueryQueryCommand
Returns
WithRecursive(string, QueryCommand, int?)
Declares a recursive common table expression. A recursive CTE body references its own name through From(string).
public CteQuery WithRecursive(string name, QueryCommand query, int? maxRecursion = null)
Parameters
namestringqueryQueryCommandmaxRecursionint?
Returns
With<TEntity, TResult>(string, InsertReturningBuilder<TEntity, TResult>)
Declares a data-modifying common table expression after the read CTEs collected so far, so
its INSERT ... SELECT body may reference them (PostgreSQL makes a CTE visible to later
ones). The returned scope is typed by the RETURNING projection.
public MutationCteQuery<TResult> With<TEntity, TResult>(string name, InsertReturningBuilder<TEntity, TResult> insert)
Parameters
namestringThe name the data-modifying CTE is declared under.
insertInsertReturningBuilder<TEntity, TResult>The returning insert that forms the CTE body.
Returns
- MutationCteQuery<TResult>
A scope that reads the mutation's returned rows.
Type Parameters
TEntityThe mapped entity type inserted by the CTE body.
TResultThe row shape the CTE returns through
RETURNING.
Exceptions
- NotSupportedException
The provider does not accept a data-modifying CTE body (only PostgreSQL does).