Table of Contents

Interface IRelationalCommand

Namespace
Microsoft.EntityFrameworkCore.Storage
Assembly
Microsoft.EntityFrameworkCore.Relational.dll

A command to be executed against a relational database.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

public interface IRelationalCommand

Properties

CommandText

Gets the command text to be executed.

string CommandText { get; }

Property Value

string

Parameters

Gets the parameters for the command.

IReadOnlyList<IRelationalParameter> Parameters { get; }

Property Value

IReadOnlyList<IRelationalParameter>

Methods

CreateDbCommand(RelationalCommandParameterObject, Guid, DbCommandMethod)

Called by the execute methods to create a DbCommand for the given DbConnection and configure timeouts and transactions.

This method is typically used by database providers (and other extensions). It is generally not used in application code.

DbCommand CreateDbCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod)

Parameters

parameterObject RelationalCommandParameterObject

Parameters for this method.

commandId Guid

The command correlation ID.

commandMethod DbCommandMethod

The method that will be called on the created command.

Returns

DbCommand

The created command.

ExecuteNonQuery(RelationalCommandParameterObject)

Executes the command with no results.

int ExecuteNonQuery(RelationalCommandParameterObject parameterObject)

Parameters

parameterObject RelationalCommandParameterObject

Parameters for this method.

Returns

int

The number of rows affected.

ExecuteNonQueryAsync(RelationalCommandParameterObject, CancellationToken)

Asynchronously executes the command with no results.

Task<int> ExecuteNonQueryAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken = default)

Parameters

parameterObject RelationalCommandParameterObject

Parameters for this method.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<int>

A task that represents the asynchronous operation. The task result contains the number of rows affected.

ExecuteReader(RelationalCommandParameterObject)

Executes the command with a RelationalDataReader result.

RelationalDataReader ExecuteReader(RelationalCommandParameterObject parameterObject)

Parameters

parameterObject RelationalCommandParameterObject

Parameters for this method.

Returns

RelationalDataReader

The result of the command.

ExecuteReaderAsync(RelationalCommandParameterObject, CancellationToken)

Asynchronously executes the command with a RelationalDataReader result.

Task<RelationalDataReader> ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken = default)

Parameters

parameterObject RelationalCommandParameterObject

Parameters for this method.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<RelationalDataReader>

A task that represents the asynchronous operation. The task result contains the result of the command.

ExecuteScalar(RelationalCommandParameterObject)

Executes the command with a single scalar result.

object ExecuteScalar(RelationalCommandParameterObject parameterObject)

Parameters

parameterObject RelationalCommandParameterObject

Parameters for this method.

Returns

object

The result of the command.

ExecuteScalarAsync(RelationalCommandParameterObject, CancellationToken)

Asynchronously executes the command with a single scalar result.

Task<object> ExecuteScalarAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken = default)

Parameters

parameterObject RelationalCommandParameterObject

Parameters for this method.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<object>

A task that represents the asynchronous operation. The task result contains the result of the command.