Skip to content

Commit

Permalink
removed automatic TotalResultsCount filling based on IQueryable\IEnum…
Browse files Browse the repository at this point in the history
…erable and removed 1 unit test that covered that
  • Loading branch information
sergey-litvinov-work committed Oct 21, 2019
1 parent 65a9765 commit c313649
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
12 changes: 0 additions & 12 deletions Saule/Queries/Pagination/PaginationInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ public IQueryable Apply(IQueryable queryable)
.Where(i => i.IsGenericType)
.Any(i => i.GetGenericTypeDefinition() == typeof(IOrderedQueryable<>));

// if we don't have totalResultsCount in the context
// then we will try to get it from IQueryable by executing one more query before Order\Skip\Take
if (!_context.TotalResultsCount.HasValue && _context.PerPage.GetValueOrDefault() != 0)
{
_context.TotalResultsCount = (int)queryable.ApplyQuery(QueryMethod.Count);
}

var ordered = isOrdered ? queryable : OrderById(queryable);

var filtered = ordered.ApplyQuery(QueryMethod.Skip, _context.Page * _context.PerPage) as IQueryable;
Expand All @@ -41,11 +34,6 @@ public IQueryable Apply(IQueryable queryable)

public IEnumerable Apply(IEnumerable queryable)
{
if (!_context.TotalResultsCount.HasValue && _context.PerPage.GetValueOrDefault() != 0)
{
_context.TotalResultsCount = (int)queryable.ApplyQuery(QueryMethod.Count);
}

var filtered = queryable.ApplyQuery(QueryMethod.Skip, _context.Page * _context.PerPage) as IEnumerable;
filtered = filtered.ApplyQuery(QueryMethod.Take, _context.PerPage) as IEnumerable;

Expand Down
1 change: 0 additions & 1 deletion Tests/Integration/JsonApiMediaTypeFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ public async Task LimitsPageSizeIsNotSet()

[InlineData("api/companies/paged-result", 0)]
[InlineData("api/companies/paged-result-first-page", 1)]
[InlineData("api/companies/paged-result-queryable", 0)]
[Theory(DisplayName = "Paged result calculates page counts")]
public async Task PagedResult(object baseUrl, int firstPageNumber)
{
Expand Down

0 comments on commit c313649

Please sign in to comment.