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 : IRelationalCommandTemplate
Inherited Members

Remarks

See Implementation of database providers and extensions for more information and examples.

Methods

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.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

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.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

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.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

PopulateFrom(IRelationalCommandTemplate)

Populates this command from the provided commandTemplate.

void PopulateFrom(IRelationalCommandTemplate commandTemplate)

Parameters

commandTemplate IRelationalCommandTemplate

A template command from which the command text and parameters will be copied.