public static async Task<IPagedList<T>> ToPagedListAsync<T>(this IQueryable<T> source, int pageIndex, int pageSize, int indexFrom = 0, CancellationToken cancellationToken = default(CancellationToken))
{
if (indexFrom > pageIndex)
{
throw new ArgumentException($"indexFrom: {indexFrom} > pageIndex: {pageIndex}, must indexFrom <= pageIndex");
}
var count = await source.CountAsync(cancellationToken).ConfigureAwait(false);
var items = await source.Skip((pageIndex - indexFrom) * pageSize)
.Take(pageSize)
.Cacheable<T>()
.ToListAsync(cancellationToken).ConfigureAwait(false);
var pagedList = new PagedList<T>()
{
PageIndex = pageIndex,
PageSize = pageSize,
IndexFrom = indexFrom,
TotalCount = count,
Items = items,
TotalPages = (int)Math.Ceiling(count / (double)pageSize)
};
return pagedList;
}
Output:
Exception message: An unhandled exception occurred while processing the request.
TypeLoadException: Could not load type 'Microsoft.EntityFrameworkCore.Query.Internal.ExpressionPrinter' from assembly 'Microsoft.EntityFrameworkCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
EFSecondLevelCache.Core.EFCacheKeyProvider.GetEFCacheKey<T>(IQueryable<T> query, Expression expression, string saltKey)
Full Stack trace:
EFSecondLevelCache.Core.EFCacheKeyProvider.GetEFCacheKey<T>(IQueryable<T> query, Expression expression, string saltKey)
EFSecondLevelCache.Core.EFCachedQueryProvider<TType>.Materialize(Expression expression, Func<object> materializer)
EFSecondLevelCache.Core.EFCachedQueryable<TType>.GetAsyncEnumerator(CancellationToken cancellationToken)
System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable<T>.GetAsyncEnumerator()
Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync<TSource>(IQueryable<TSource> source, CancellationToken cancellationToken)
Microsoft.EntityFrameworkCore.IQueryablePageListExtensions.ToPagedListAsync<T>(IQueryable<T> source, int pageIndex, int pageSize, int indexFrom, CancellationToken cancellationToken) in IQueryablePageListExtensions.cs
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.
Summary of the issue
Migrating to dotnetcore 3 (preview 8) from version 2.2, seems to break caching.
Environment
Example code/Steps to reproduce:
Output: