Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created September 3, 2019 12:47
Show Gist options
  • Select an option

  • Save ntakouris/e166a580fd8065903c75764a94a68db7 to your computer and use it in GitHub Desktop.

Select an option

Save ntakouris/e166a580fd8065903c75764a94a68db7 to your computer and use it in GitHub Desktop.
public async Task<List<Post>> GetPostsAsync(PaginationFilter paginationFilter = null)
{
if (paginationFilter == null)
{
return await _dataContext.Posts.Include(x => x.Tags).ToListAsync();
}
var skip = (paginationFilter.PageNumber - 1) * paginationFilter.PageSize;
return await _dataContext.Posts.Include(x => x.Tags)
.Skip(skip).Take(paginationFilter.PageSize).ToListAsync();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment