Compartilhar via


RelationalStorageExtensions.ExecuteAsync Método

Definição

Sobrecargas

ExecuteAsync(IRelationalStorage, String, CancellationToken)

IRelationalStorage Usa com ReflectionSelector<TResult>(IDataRecord).

ExecuteAsync(IRelationalStorage, String, Object, CancellationToken)

IRelationalStorage Usa com ReflectionSelector<TResult>(IDataRecord).

ExecuteAsync(IRelationalStorage, String, CancellationToken)

public static System.Threading.Tasks.Task<int> ExecuteAsync (this Orleans.SqlUtils.IRelationalStorage storage, string query, System.Threading.CancellationToken cancellationToken = default);
static member ExecuteAsync : Orleans.SqlUtils.IRelationalStorage * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function ExecuteAsync (storage As IRelationalStorage, query As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Integer)

Parâmetros

storage
IRelationalStorage

O armazenamento a ser usado.

query
String

Executa uma determinada instrução. Especialmente destinado a usar com consultas INSERT, UPDATE, DELETE ou DDL .

cancellationToken
CancellationToken

O token de cancelamento. Assume o padrão de None.

Retornos

Contagem de linhas afetadas.

Aplica-se a

ExecuteAsync(IRelationalStorage, String, Object, CancellationToken)

public static System.Threading.Tasks.Task<int> ExecuteAsync (this Orleans.SqlUtils.IRelationalStorage storage, string query, object parameters, System.Threading.CancellationToken cancellationToken = default);
static member ExecuteAsync : Orleans.SqlUtils.IRelationalStorage * string * obj * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function ExecuteAsync (storage As IRelationalStorage, query As String, parameters As Object, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Integer)

Parâmetros

storage
IRelationalStorage

O armazenamento a ser usado.

query
String

Executa uma determinada instrução. Especialmente destinado a usar com consultas INSERT, UPDATE, DELETE ou DDL .

parameters
Object

Adiciona parâmetros à consulta. Os nomes de parâmetro devem corresponder aos definidos na consulta.

cancellationToken
CancellationToken

O token de cancelamento. Assume o padrão de None.

Retornos

Contagem de linhas afetadas.

Exemplos

Isso usa reflexão para fornecer parâmetros para uma consulta de execução que lê apenas a contagem de linhas afetadas, se disponível.

//Here reflection (<seealso cref="M:Orleans.SqlUtils.DbExtensions.ReflectionParameterProvider``1(System.Data.IDbCommand,``0,System.Collections.Generic.IReadOnlyDictionary{System.String,System.String})"></seealso>)
is used to match parameter names as well as to read back the results (<seealso cref="M:Orleans.SqlUtils.DbExtensions.ReflectionSelector``1(System.Data.IDataRecord)"></seealso>).
var query = "IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = @tname) CREATE TABLE Test(Id INT PRIMARY KEY IDENTITY(1, 1) NOT NULL);"
await db.ExecuteAsync(query, new { tname = "test_table" });

Aplica-se a