public async Task <Page <UserRoleGrid> > GetGrid(GridRequest gridRequest, int?userId, int?roleId) { if (!userId.HasValue && !roleId.HasValue) { throw new CallerException("UserId or RoleId is required"); } var data = new Page <UserRoleGrid>(); using (var uow = new UnitOfWork(Context)) { var repo = new UserRoleRepository(uow); var query = repo.GetAllForGrid(userId, roleId); var dataGridLogic = new DataGridLogic <UserRoleGrid>(gridRequest, query); data.Records = await dataGridLogic.GetResults(); //TODO this wont work data.PageSize = dataGridLogic.PageSize; data.PageOffset = dataGridLogic.PageOffset; data.TotalRecordCount = dataGridLogic.TotalRecordCount; data.SortExpression = dataGridLogic.SortExpression; } return(data); }