Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ObjectContext::ExecuteStoreCommandAsync Method

Entity Framework 6.0
 

Asynchronously executes a command against the database server that does not return a sequence of objects. The command is specified using the server's native query language, such as SQL.

Namespace:   System.Data.Entity.Core.Objects
Assembly:  EntityFramework (in EntityFramework.dll)

NameDescription
System_CAPS_pubmethodExecuteStoreCommandAsync(String^, CancellationToken, array<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));

System_CAPS_pubmethodExecuteStoreCommandAsync(String^, array<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));

System_CAPS_pubmethodExecuteStoreCommandAsync(TransactionalBehavior, String^, CancellationToken, array<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));

System_CAPS_pubmethodExecuteStoreCommandAsync(TransactionalBehavior, String^, array<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));

Return to top

ObjectContext::ExecuteStoreCommandAsync Method (String^, CancellationToken, array<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 Task<int>^ ExecuteStoreCommandAsync(
	String^ commandText,
	CancellationToken cancellationToken,
	... array<Object^>^ parameters
)

Parameters

commandText
Type: System::String^

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

cancellationToken
Type: System.Threading::CancellationToken

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

parameters
Type: array<System::Object^>^

The parameter values to use for the query.

Return Value

Type: System.Threading.Tasks::Task<Int32>^

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

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.

Return to top

ObjectContext::ExecuteStoreCommandAsync Method (String^, array<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:
Task<int>^ ExecuteStoreCommandAsync(
	String^ commandText,
	... array<Object^>^ parameters
)

Parameters

commandText
Type: System::String^

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

parameters
Type: array<System::Object^>^

The parameter values to use for the query.

Return Value

Type: System.Threading.Tasks::Task<Int32>^

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

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.

Return to top

ObjectContext::ExecuteStoreCommandAsync Method (TransactionalBehavior, String^, CancellationToken, array<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 Task<int>^ ExecuteStoreCommandAsync(
	TransactionalBehavior transactionalBehavior,
	String^ commandText,
	CancellationToken cancellationToken,
	... array<Object^>^ parameters
)

Parameters

transactionalBehavior
Type: System.Data.Entity::TransactionalBehavior

Controls the creation of a transaction for this command.

commandText
Type: System::String^

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

cancellationToken
Type: System.Threading::CancellationToken

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

parameters
Type: array<System::Object^>^

The parameter values to use for the query.

Return Value

Type: System.Threading.Tasks::Task<Int32>^

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

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.

Return to top

ObjectContext::ExecuteStoreCommandAsync Method (TransactionalBehavior, String^, array<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:
Task<int>^ ExecuteStoreCommandAsync(
	TransactionalBehavior transactionalBehavior,
	String^ commandText,
	... array<Object^>^ parameters
)

Parameters

transactionalBehavior
Type: System.Data.Entity::TransactionalBehavior

Controls the creation of a transaction for this command.

commandText
Type: System::String^

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

parameters
Type: array<System::Object^>^

The parameter values to use for the query.

Return Value

Type: System.Threading.Tasks::Task<Int32>^

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

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.

Return to top
Show: