public static void FillDataSet <T>(GridViewDataSet <T> dataSet, IQuery <T> query) { query.Skip = dataSet.PageIndex * dataSet.PageSize; query.Take = dataSet.PageSize; query.SortCriteria.Clear(); query.AddSortCriteria(dataSet.SortExpression, dataSet.SortDescending ? SortDirection.Descending : SortDirection.Ascending); dataSet.TotalItemsCount = query.GetTotalRowCount(); dataSet.Items = query.Execute(); }
/// <summary> /// Fills the GridViewDataSet from the specified query object. /// </summary> public static void LoadFromQuery <T>(this GridViewDataSet <T> dataSet, IQuery <T> query) { query.Skip = dataSet.PagingOptions.PageIndex * dataSet.PagingOptions.PageSize; query.Take = dataSet.PagingOptions.PageSize; query.ClearSortCriteria(); if (!string.IsNullOrEmpty(dataSet.SortingOptions.SortExpression)) { query.AddSortCriteria(dataSet.SortingOptions.SortExpression, dataSet.SortingOptions.SortDescending ? SortDirection.Descending : SortDirection.Ascending); } dataSet.PagingOptions.TotalItemsCount = query.GetTotalRowCount(); dataSet.Items = query.Execute(); }
public async Task <DialogListDTO> ListDialogs(DialogFilter filter, int page = 0) { IQuery <DialogDTO> query = GetChatQuery(filter); query.Skip = (page > 0 ? page - 1 : 0) * DialogPageSize; query.Take = DialogPageSize; query.AddSortCriteria(s => s.Name, SortDirection.Descending); return(new DialogListDTO { RequestedPage = page, ResultCount = query.GetTotalRowCount(), ResultDialogs = query.Execute(), Filter = filter }); }
public async Task <MessageListDTO> ListDialogMessages(MessageFilter filter, int page = 0) { IQuery <MessageDTO> query = GetMessageQuery(filter); query.Skip = (page > 0 ? page - 1 : 0) * ChatMessagePageSize; query.Take = ChatMessagePageSize; query.AddSortCriteria(s => s.Time, SortDirection.Descending); return(new MessageListDTO { RequestedPage = page, ResultCount = query.GetTotalRowCount(), ResultMessages = query.Execute(), Filter = filter }); }
public async Task <UserListDTO> ListUsers(UserFilter filter, int page = 0) { IQuery <UserDTO> query = GetQuery(filter); query.Skip = (page > 0 ? page - 1 : 0) * UserPageSize; query.Take = UserPageSize; query.AddSortCriteria(x => x.Name); return(new UserListDTO { RequestedPage = page, ResultCount = query.GetTotalRowCount(), ResultUsers = query.Execute(), Filter = filter }); }
/// <summary> /// Fills the GridViewDataSet from the specified query object. /// </summary> public static async Task LoadFromQueryAsync <T>(this GridViewDataSet <T> dataSet, IQuery <T> query, CancellationToken cancellationToken = default) { query.Skip = dataSet.PagingOptions.PageIndex * dataSet.PagingOptions.PageSize; query.Take = dataSet.PagingOptions.PageSize; query.ClearSortCriteria(); if (!string.IsNullOrEmpty(dataSet.SortingOptions.SortExpression)) { query.AddSortCriteria(dataSet.SortingOptions.SortExpression, dataSet.SortingOptions.SortDescending ? SortDirection.Descending : SortDirection.Ascending); } dataSet.PagingOptions.TotalItemsCount = await query.GetTotalRowCountAsync(cancellationToken); dataSet.Items = await query.ExecuteAsync(cancellationToken); dataSet.IsRefreshRequired = false; }