Table of Contents

Class SqlInsertStatement

Namespace
Utils.Data.Sql
Assembly
Utils.Data.dll

Represents a parsed INSERT statement.

public sealed class SqlInsertStatement : SqlStatement
Inheritance
SqlInsertStatement
Inherited Members
Extension Methods

Constructors

SqlInsertStatement(SqlSegment, SqlSegment?, SqlStatement?, SqlSegment?, SqlSegment?, WithClause?)

Initializes a new instance of the SqlInsertStatement class.

public SqlInsertStatement(SqlSegment target, SqlSegment? values, SqlStatement? sourceQuery, SqlSegment? output, SqlSegment? returning, WithClause? withClause)

Parameters

target SqlSegment

The target segment identifying the destination of the insert.

values SqlSegment

The VALUES segment when the insert uses literal values.

sourceQuery SqlStatement

The statement used as data source when the insert uses a query.

output SqlSegment

The OUTPUT segment if present.

returning SqlSegment

The RETURNING segment if present.

withClause WithClause

Optional CTE definitions.

Properties

InsertPart

Gets the INSERT clause represented as a typed part.

public InsertPart InsertPart { get; }

Property Value

InsertPart

IntoPart

Gets the INTO clause represented as a typed part.

public IntoPart IntoPart { get; }

Property Value

IntoPart

Output

Gets the OUTPUT segment when present.

public SqlSegment? Output { get; }

Property Value

SqlSegment

Returning

Gets the RETURNING segment when present.

public SqlSegment? Returning { get; }

Property Value

SqlSegment

SourceQuery

Gets the source statement when the insert pulls data from a query.

public SqlStatement? SourceQuery { get; }

Property Value

SqlStatement

Target

Gets the target segment describing the destination table or expression.

public SqlSegment Target { get; }

Property Value

SqlSegment

Values

Gets the VALUES segment when the statement inserts literal values.

public SqlSegment? Values { get; }

Property Value

SqlSegment

ValuesPart

Gets the VALUES clause represented as a typed part when present.

public ValuesPart? ValuesPart { get; }

Property Value

ValuesPart

Methods

BuildSql()

Builds the canonical inline SQL representation of the statement.

protected override string BuildSql()

Returns

string

The inline SQL string representing the statement.

EnsureOutputSegment()

Ensures an OUTPUT segment exists and returns it.

public SqlSegment EnsureOutputSegment()

Returns

SqlSegment

The existing or newly created OUTPUT segment.

EnsureReturningSegment()

Ensures a RETURNING segment exists and returns it.

public SqlSegment EnsureReturningSegment()

Returns

SqlSegment

The existing or newly created RETURNING segment.

EnsureValuesSegment()

Ensures a VALUES segment exists and returns it.

public SqlSegment EnsureValuesSegment()

Returns

SqlSegment

The existing or newly created VALUES segment.

Exceptions

InvalidOperationException

Thrown when the insert statement already uses a source query.

GetChildStatements()

Retrieves the child statements referenced by this statement.

protected override IEnumerable<SqlStatement> GetChildStatements()

Returns

IEnumerable<SqlStatement>

An enumerable of nested statements.