Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
improvement on paging LINQ
Browse files Browse the repository at this point in the history
  • Loading branch information
imranmomin committed Dec 26, 2018
1 parent e00801b commit 78a5eec
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Hangfire.AzureDocumentDB/DocumentDbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ public override List<string> GetRangeFromSet(string key, int startingFrom, int e
if (key == null) throw new ArgumentNullException(nameof(key));

FeedOptions feedOptions = new FeedOptions { MaxItemCount = endingAt + 1 };
endingAt += 1 - startingFrom;

return Storage.Client.CreateDocumentQuery<Set>(Storage.CollectionUri, feedOptions)
.Where(s => s.DocumentType == DocumentTypes.Set && s.Key == key)
.OrderBy(s => s.Score)
.ToQueryResult()
.OrderBy(s => s.CreatedOn)
.Select((s, i) => new { s.Value, Index = i })
.Where(s => s.Index >= startingFrom && s.Index <= endingAt)
.Select(s => s.Value)
.ToQueryResult()
.Skip(startingFrom)
.Take(endingAt)
.ToList();
}

Expand Down Expand Up @@ -487,15 +487,15 @@ public override List<string> GetRangeFromList(string key, int startingFrom, int
if (key == null) throw new ArgumentNullException(nameof(key));

FeedOptions feedOptions = new FeedOptions { MaxItemCount = endingAt + 1 };
endingAt += 1 - startingFrom;

return Storage.Client.CreateDocumentQuery<List>(Storage.CollectionUri, feedOptions)
.Where(l => l.DocumentType == DocumentTypes.List && l.Key == key)
.OrderByDescending(l => l.CreatedOn)
.Select(l => l.Value)
.ToQueryResult()
.Select((l, i) => new { Value = l, Index = i })
.Where(l => l.Index >= startingFrom && l.Index <= endingAt)
.Select(l => l.Value)
.Skip(startingFrom)
.Take(endingAt)
.ToList();
}

Expand Down

0 comments on commit 78a5eec

Please sign in to comment.