Skip to content

ExecuteExtensions.ExecuteQueryAsync

Mike King edited this page Sep 30, 2025 · 2 revisions

ExecuteExtensions.ExecuteQueryAsync Method

Overloads
ExecuteQueryAsync<TSource>(this DatabaseFacade, string, CancellationToken, IEnumerable<object>) Executes a query.
ExecuteQueryAsync<TSource>(this DatabaseFacade, FormattableString, CancellationToken) Executes a query.

ExecuteExtensions.ExecuteQueryAsync<TSource>(this DatabaseFacade, string, CancellationToken, IEnumerable<object>) Method

Executes a query.

public static System.Threading.Tasks.Task<System.Collections.Generic.IList<TSource>> ExecuteQueryAsync<TSource>(this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade database, string sql, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken), System.Collections.Generic.IEnumerable<object?> parameters)
    where TSource : class;

Type parameters

TSource

The type of the elements of the source.

Parameters

database Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade

The Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade for the context.

sql System.String

The SQL query to execute.

cancellationToken System.Threading.CancellationToken

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

parameters System.Collections.Generic.IEnumerable<System.Object>

Parameters to use with the SQL.

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IList<TSource>>
A System.Collections.Generic.IList<> containing the results of the query.

ExecuteExtensions.ExecuteQueryAsync<TSource>(this DatabaseFacade, FormattableString, CancellationToken) Method

Executes a query.

public static System.Threading.Tasks.Task<System.Collections.Generic.IList<TSource>> ExecuteQueryAsync<TSource>(this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade database, System.FormattableString sql, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken))
    where TSource : class;

Type parameters

TSource

The type of the elements of the source.

Parameters

database Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade

The Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade for the context.

sql System.FormattableString

The System.FormattableString representing a SQL query with parameters.

cancellationToken System.Threading.CancellationToken

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

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IList<TSource>>
A System.Collections.Generic.IList<> containing the results of the query.

Clone this wiki locally