Skip to content

Commit

Permalink
Remove async usage in ListImplementation due to dotnet/efcore#9038
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Oct 31, 2017
1 parent 54715cc commit f57e408
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/IntelliTect.Coalesce/Controllers/BaseApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ protected virtual IQueryable<T> 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<ListResult> ListImplementation(ListParameters listParameters)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
try
{
Expand Down Expand Up @@ -166,9 +170,11 @@ protected async Task<ListResult> 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;
Expand All @@ -188,8 +194,11 @@ protected async Task<ListResult> ListImplementation(ListParameters listParameter

// Make the database call
IEnumerable<T> 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);
Expand Down

0 comments on commit f57e408

Please sign in to comment.