Skip to main content
.NET Framework 4.6.2+

Session.ExecuteNonQueryAsync(CancellationToken, String, String[], QueryParameterCollection) Method

Asynchronously executes the specified SQL statement and returns the number of rows affected.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.2.dll

Declaration

public Task<int> ExecuteNonQueryAsync(
    CancellationToken cancellationToken,
    string sql,
    string[] parameterNames,
    QueryParameterCollection parameters
)

Parameters

Name Type Description
cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

sql String

Specifies an SQL statement.

parameterNames String[]

Specifies parameter names.

parameters QueryParameterCollection

Specifies query parameter values.

Returns

Type Description
Task<Int32>

A Task<TResult> that returns a number of affected rows.

Remarks

Use the ExecuteNonQueryAsync method to execute SQL statements that do not produce result sets, such as UPDATE, INSERT, and DELETE statements.

Use QueryParameterCollection to pass strongly-typed parameters. See examples here: Always Encrypted (SQL Server only).

To learn more about executing SQL statements in XPO, refer to Direct SQL Queries.

Note

The ExecuteNonQueryAsync method sends statements directly, so the correct statement syntax and parameter names format depends on a particular database server.

See Also