Skip to content

Commit

Permalink
Fox for Orderby
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry McIntyre authored and Harry McIntyre committed Nov 17, 2016
1 parent efa6010 commit fc09b25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions LinqToAnything.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,16 @@ public void CanDoAnOptimizedCount()
[Test]
public void CanApplyAQueryInfo()
{
var queryable = Enumerable.Range(1, 100).Select(i => new SomeEntity() { Name = "User" + i, Index = i }).ToArray().AsQueryable();
var queryable = Enumerable.Range(1, 100)
.Select(i => new SomeEntity()
{
Name = "User" + i, Index = i
})
.ToArray().AsQueryable();


Func<QueryInfo, IEnumerable<SomeEntity>> getPageFromDataSource = (info) =>
{
return info.ApplyTo(queryable);
};
var pq = new DelegateQueryable<SomeEntity>(getPageFromDataSource);
var pq = new DelegateQueryable<SomeEntity>((info) => info.ApplyTo(queryable));

Assert.AreEqual(90, pq.OrderByDescending(o => o.Index).Skip(10).Take(1).Single().Index);
}

Expand Down
2 changes: 1 addition & 1 deletion LinqToAnything/QueryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public IQueryable<T> ApplyTo<T>(IQueryable<T> q)
var orderBy = qi.OrderBy.Name;
if (this.OrderBy.Direction == OrderBy.OrderByDirection.Desc)
orderBy += " descending";
q.OrderBy(orderBy);
q = q.OrderBy(orderBy);
}

if (qi.Skip > 0) q = q.Skip(qi.Skip);
Expand Down

0 comments on commit fc09b25

Please sign in to comment.