SortSpareParts() public static method

public static SortSpareParts ( IQueryable spareParts, string sortExpression, SortDirection, sortDirection ) : IQueryable
spareParts IQueryable
sortExpression string
sortDirection SortDirection,
return IQueryable
示例#1
0
        protected void SparePartsGridView_Sorting(object sender, GridViewSortEventArgs e)
        {
            SortDirection sortDirection = SortingUtility.GetSortDirection(ViewState);

            ViewState[CarServiceConstants.SORT_DIRECTION_VIEW_STATE_ATTR]  = sortDirection;
            ViewState[CarServiceConstants.SORT_EXPRESSION_VIEW_STATE_ATTR] = e.SortExpression;
            IQueryable <SparePart> spareParts       = this.persister.GetSpareParts();
            IQueryable <SparePart> sortedSpareParts = SortingUtility.SortSpareParts(spareParts, e.SortExpression, sortDirection);

            BindSparePartsGrid(sortedSpareParts);
        }
示例#2
0
        private void BindSparePartsGrid()
        {
            object sortDirectionObj           = ViewState[CarServiceConstants.SORT_DIRECTION_VIEW_STATE_ATTR];
            object sortExpressionObj          = ViewState[CarServiceConstants.SORT_EXPRESSION_VIEW_STATE_ATTR];
            IQueryable <SparePart> spareParts = this.persister.GetSpareParts();
            IQueryable <SparePart> sortedSpareParts;

            if (sortDirectionObj != null && sortExpressionObj != null)
            {
                sortedSpareParts = SortingUtility.SortSpareParts(spareParts, sortExpressionObj.ToString(),
                                                                 (SortDirection)sortDirectionObj);
            }
            else
            {
                ViewState[CarServiceConstants.SORT_DIRECTION_VIEW_STATE_ATTR]  = SortDirection.Ascending;
                ViewState[CarServiceConstants.SORT_EXPRESSION_VIEW_STATE_ATTR] = CarServiceConstants.SPARE_PART_ID_SORT_EXPRESSION;
                sortedSpareParts = spareParts;
            }
            BindSparePartsGrid(sortedSpareParts);
        }