ObjectContext.ExecuteStoreCommandAsync ObjectContext.ExecuteStoreCommandAsync ObjectContext.ExecuteStoreCommandAsync Method

Definition

Overloads

ExecuteStoreCommandAsync(String, Object[]) ExecuteStoreCommandAsync(String, Object[]) ExecuteStoreCommandAsync(String, Object[])

Asynchronously executes an arbitrary command directly against the data source using the existing connection. The command is specified using the server's native query language, such as SQL.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreCommandAsync(TransactionalBehavior, String, Object[]) ExecuteStoreCommandAsync(TransactionalBehavior, String, Object[])

Asynchronously executes an arbitrary command directly against the data source using the existing connection. The command is specified using the server's native query language, such as SQL.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreCommandAsync(String, CancellationToken, Object[]) ExecuteStoreCommandAsync(String, CancellationToken, Object[])

Asynchronously executes an arbitrary command directly against the data source using the existing connection. The command is specified using the server's native query language, such as SQL.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreCommandAsync(TransactionalBehavior, String, CancellationToken, Object[]) ExecuteStoreCommandAsync(TransactionalBehavior, String, CancellationToken, Object[])

Asynchronously executes an arbitrary command directly against the data source using the existing connection. The command is specified using the server's native query language, such as SQL.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

ExecuteStoreCommandAsync(String, Object[]) ExecuteStoreCommandAsync(String, Object[]) ExecuteStoreCommandAsync(String, Object[])

Asynchronously executes an arbitrary command directly against the data source using the existing connection. The command is specified using the server's native query language, such as SQL.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

public System.Threading.Tasks.Task<int> ExecuteStoreCommandAsync (string commandText, params object[] parameters);
member this.ExecuteStoreCommandAsync : string * obj[] -> System.Threading.Tasks.Task<int>
Public Function ExecuteStoreCommandAsync (commandText As String, ParamArray parameters As Object()) As Task(Of Integer)

Parameters

commandText
String String String

The command specified in the server's native query language.

parameters
Object[]

The parameter values to use for the query.

Returns

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

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

If there isn't an existing local transaction a new transaction will be used

to execute the command.

ExecuteStoreCommandAsync(TransactionalBehavior, String, Object[]) ExecuteStoreCommandAsync(TransactionalBehavior, String, Object[])

Asynchronously executes an arbitrary command directly against the data source using the existing connection. The command is specified using the server's native query language, such as SQL.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

public System.Threading.Tasks.Task<int> ExecuteStoreCommandAsync (System.Data.Entity.TransactionalBehavior transactionalBehavior, string commandText, params object[] parameters);
member this.ExecuteStoreCommandAsync : System.Data.Entity.TransactionalBehavior * string * obj[] -> System.Threading.Tasks.Task<int>

Parameters

transactionalBehavior
TransactionalBehavior TransactionalBehavior TransactionalBehavior

Controls the creation of a transaction for this command.

commandText
String String String

The command specified in the server's native query language.

parameters
Object[]

The parameter values to use for the query.

Returns

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

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

ExecuteStoreCommandAsync(String, CancellationToken, Object[]) ExecuteStoreCommandAsync(String, CancellationToken, Object[])

Asynchronously executes an arbitrary command directly against the data source using the existing connection. The command is specified using the server's native query language, such as SQL.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

public virtual System.Threading.Tasks.Task<int> ExecuteStoreCommandAsync (string commandText, System.Threading.CancellationToken cancellationToken, params object[] parameters);
abstract member ExecuteStoreCommandAsync : string * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<int>
override this.ExecuteStoreCommandAsync : string * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<int>

Parameters

commandText
String String String

The command specified in the server's native query language.

cancellationToken
CancellationToken CancellationToken CancellationToken

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

parameters
Object[]

The parameter values to use for the query.

Returns

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

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

If there isn't an existing local transaction a new transaction will be used

to execute the command.

ExecuteStoreCommandAsync(TransactionalBehavior, String, CancellationToken, Object[]) ExecuteStoreCommandAsync(TransactionalBehavior, String, CancellationToken, Object[])

Asynchronously executes an arbitrary command directly against the data source using the existing connection. The command is specified using the server's native query language, such as SQL.

As with any API that accepts SQL it is important to parameterize any user input to protect against a SQL injection attack. You can include parameter place holders in the SQL query string and then supply parameter values as additional arguments. Any parameter values you supply will automatically be converted to a DbParameter. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @p0", userSuppliedAuthor); Alternatively, you can also construct a DbParameter and supply it to SqlQuery. This allows you to use named parameters in the SQL query string. context.ExecuteStoreCommandAsync("UPDATE dbo.Posts SET Rating = 5 WHERE Author = @author", new SqlParameter("@author", userSuppliedAuthor));

public virtual System.Threading.Tasks.Task<int> ExecuteStoreCommandAsync (System.Data.Entity.TransactionalBehavior transactionalBehavior, string commandText, System.Threading.CancellationToken cancellationToken, params object[] parameters);
abstract member ExecuteStoreCommandAsync : System.Data.Entity.TransactionalBehavior * string * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<int>
override this.ExecuteStoreCommandAsync : System.Data.Entity.TransactionalBehavior * string * System.Threading.CancellationToken * obj[] -> System.Threading.Tasks.Task<int>

Parameters

transactionalBehavior
TransactionalBehavior TransactionalBehavior TransactionalBehavior

Controls the creation of a transaction for this command.

commandText
String String String

The command specified in the server's native query language.

cancellationToken
CancellationToken CancellationToken CancellationToken

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

parameters
Object[]

The parameter values to use for the query.

Returns

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

Remarks

Multiple active operations on the same context instance are not supported. Use 'await' to ensure

that any asynchronous operations have completed before calling another method on this context.

Applies to