From f57e40831cf0e1e4426f0d0e6c6a68b7e76cc6c0 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Mon, 30 Oct 2017 17:19:54 -0700 Subject: [PATCH] Remove async usage in ListImplementation due to https://github.com/aspnet/EntityFrameworkCore/issues/9038 --- .../Controllers/BaseApiController.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/IntelliTect.Coalesce/Controllers/BaseApiController.cs b/src/IntelliTect.Coalesce/Controllers/BaseApiController.cs index 784732de1..0335dc7da 100644 --- a/src/IntelliTect.Coalesce/Controllers/BaseApiController.cs +++ b/src/IntelliTect.Coalesce/Controllers/BaseApiController.cs @@ -99,7 +99,11 @@ protected virtual IQueryable GetDataSource(ListParameters listParameters) return DataSource ?? ReadOnlyDataSource; } + // CS1998 disabled because our async usage within was removed due to https://github.com/aspnet/EntityFrameworkCore/issues/6039. + // Restore async usage once fix is available. +#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously protected async Task ListImplementation(ListParameters listParameters) +#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { try { @@ -166,9 +170,11 @@ protected async Task ListImplementation(ListParameters listParameter // Get a count int totalCount; - if (result.Provider is IAsyncQueryProvider) totalCount = await result.CountAsync(); - else totalCount = result.Count(); - + // Async disabled because of https://github.com/aspnet/EntityFrameworkCore/issues/9038. + // Renable once microsoft releases the fix and we upgrade our references. + //if (result.Provider is IAsyncQueryProvider) totalCount = await result.CountAsync(); + //else totalCount = result.Count(); + totalCount = result.Count(); // Add paging. int page = listParameters.Page ?? 1; @@ -188,8 +194,11 @@ protected async Task ListImplementation(ListParameters listParameter // Make the database call IEnumerable result2; - if (result.Provider is IAsyncQueryProvider) result2 = await result.ToListAsync(); - else result2 = result.ToList(); + // Async disabled because of https://github.com/aspnet/EntityFrameworkCore/issues/9038. + // Renable once microsoft releases the fix and we upgrade our references. + //if (result.Provider is IAsyncQueryProvider) result2 = await result.ToListAsync(); + //else result2 = result.ToList(); + result2 = result.ToList(); // Add external entities result2.IncludesExternal(listParameters.Includes);