public static IQueryable <T> LimitResults <T>(IQueryable <T> queryable, int limit, out bool resultsLimited) { TruncatedCollection <T> truncatedCollection = new TruncatedCollection <T>(queryable, limit); resultsLimited = truncatedCollection.IsTruncated; return(truncatedCollection.AsQueryable()); }
public void Property_PageSize() { int pageSize = 42; TruncatedCollection <int> collection = new TruncatedCollection <int>(new[] { 1, 2, 3 }, pageSize); Assert.Equal(pageSize, collection.PageSize); }
public void GetEnumerator_DoesNotTruncate_IfPageSizeIsGreaterThanOrEqualToCollectionSize(int pageSize) { TruncatedCollection <int> collection = new TruncatedCollection <int>(new[] { 1, 2, 3 }, pageSize); Assert.Equal(new[] { 1, 2, 3 }, collection); }
public void GetEnumerator_Truncates_IfPageSizeIsLessThanCollectionSize() { TruncatedCollection <int> collection = new TruncatedCollection <int>(new[] { 1, 2, 3 }, pageSize: 2); Assert.Equal(new[] { 1, 2 }, collection); }
public void Property_IsTruncated(int pageSize, bool expectedResult) { TruncatedCollection <int> collection = new TruncatedCollection <int>(new[] { 1, 2, 3 }, pageSize); Assert.Equal(expectedResult, collection.IsTruncated); }