public async Task <IPage <T> > PageAsync( int pageSize, byte[] pagingState) { byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAllAsync(); var slice = records.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } var page = new PageContainer <T>(currentPagingState, pagingState, slice); return(page); }
public static string SerializeToBase64String(this PagingState pagingState) { if (pagingState == null) { return(null); } byte[] bytes = pagingState.Serialize(); var psString = Convert.ToBase64String(bytes); return(psString); }