Table of Contents

Class CteQuery

Namespace
NextORM.Core
Assembly
nextorm.core.dll

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

IReadOnlyList<CteDefinition>

Methods

From(CteDefinition)

Starts a query whose source is cte.

public EntityBuilder<TableAlias> From(CteDefinition cte)

Parameters

cte CteDefinition

Returns

EntityBuilder<TableAlias>

From(string)

Starts a query whose source is the CTE declared as cteName.

public EntityBuilder<TableAlias> From(string cteName)

Parameters

cteName string

Returns

EntityBuilder<TableAlias>

With(string, QueryCommand)

Declares a non-recursive common table expression.

public CteQuery With(string name, QueryCommand query)

Parameters

name string
query QueryCommand

Returns

CteQuery

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

name string
query QueryCommand
maxRecursion int?

Returns

CteQuery

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

name string

The name the data-modifying CTE is declared under.

insert InsertReturningBuilder<TEntity, TResult>

The returning insert that forms the CTE body.

Returns

MutationCteQuery<TResult>

A scope that reads the mutation's returned rows.

Type Parameters

TEntity

The mapped entity type inserted by the CTE body.

TResult

The row shape the CTE returns through RETURNING.

Exceptions

NotSupportedException

The provider does not accept a data-modifying CTE body (only PostgreSQL does).