AsyncQueryExecutorSupplier modiied so it looks-up multiple IAsyncQueryExecutor registrations and returns the first supporting match. (#2730)

Co-authored-by: Vincent Baaij <vnbaaij@outlook.com>
This commit is contained in:
Miguel Hasse de Oliveira 2024-10-09 12:28:55 +01:00 коммит произвёл GitHub
Родитель 41542e23f6
Коммит 567215f4d7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -25,9 +25,9 @@ internal static class AsyncQueryExecutorSupplier
{
if (queryable is not null)
{
var executor = services.GetService<IAsyncQueryExecutor>();
var executors = services.GetServices<IAsyncQueryExecutor>();
if (executor is null)
if (executors is null)
{
// It's useful to detect if the developer is unaware that they should be using the EF adapter, otherwise
// they will likely never notice and simply deploy an inefficient app that blocks threads on each query.
@ -37,9 +37,15 @@ internal static class AsyncQueryExecutorSupplier
throw new InvalidOperationException($"The supplied {nameof(IQueryable)} is provided by Entity Framework. To query it efficiently, see https://github.com/microsoft/fluentui-blazor#use-the-datagrid-component-with-ef-core for the needed steps.");
}
}
else if (executor.IsSupported(queryable))
else
{
return executor;
foreach (var executor in executors)
{
if (executor.IsSupported(queryable))
{
return executor;
}
}
}
}