Skip to main content
.NET 6.0+

Session.ExecuteQueryWithMetadataAsync(String, Object[], CancellationToken) Method

Asynchronously executes the specified SQL query and returns its result set along with the types and names of retrieved columns.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.1.dll

NuGet Package: DevExpress.Xpo

Declaration

public Task<SelectedData> ExecuteQueryWithMetadataAsync(
    string sql,
    object[] parameterValues,
    CancellationToken cancellationToken = default(CancellationToken)
)

Parameters

Name Type Description
sql String

Specifies an SQL statement.

parameterValues Object[]

An array of objects specifying parameters to pass to the database server along with the query.

Optional Parameters

Name Type Default Description
cancellationToken CancellationToken null

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

Returns

Type Description
Task<SelectedData>

A Task<TResult> that returns a result set compatible with XPDataView.

Remarks

Use the ExecuteQueryWithMetadataAsync method to query data stores for resulting sets. You can visualize resulting sets using the XPDataView. Refer to this article for additional information: How to: Access Data in SQL Query Results.

The connection provider automatically generates sequential parameter names (p0, p1, p2 …). To specify custom parameter names, use the overloaded ExecuteQueryWithMetadataAsync(String, String[], Object[], CancellationToken) method.

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

Note

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

See Also