Session.ExecuteQueryWithMetadataAsync(String, QueryParameterCollection, 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.2.dll
#Declaration
public Task<SelectedData> ExecuteQueryWithMetadataAsync(
string sql,
QueryParameterCollection parameters,
CancellationToken cancellationToken = default(CancellationToken)
)
#Parameters
Name | Type | Description |
---|---|---|
sql | String | Specifies an SQL statement. |
parameters | Query |
Specifies query parameter values. |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
cancellation |
Cancellation |
null | A Cancellation |
#Returns
Type | Description |
---|---|
Task<Selected |
A Task |
#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.
Use QueryParameterCollection to pass strongly-typed parameters. See examples here: Always Encrypted (SQL Server only).
The connection provider automatically generates sequential parameter names (p0, p1, p2 …). To specify custom parameter names, use the overloaded ExecuteQueryWithMetadataAsync(String, String[], QueryParameterCollection, CancellationToken) method.
To learn more about executing SQL statements in XPO, refer to Direct SQL Queries.
Note
The Execute