SortAutomobiles() public static method

public static SortAutomobiles ( IQueryable automobiles, string sortExpression, SortDirection, sortDirection ) : IQueryable
automobiles IQueryable
sortExpression string
sortDirection SortDirection,
return IQueryable
Beispiel #1
0
        protected void CarsGridView_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 <Automobile> automobiles       = this.persister.GetAutomobiles();
            IQueryable <Automobile> sortedAutomobiles = SortingUtility.SortAutomobiles(automobiles, e.SortExpression, sortDirection);

            BindAutomobilesGrid(sortedAutomobiles);
        }
Beispiel #2
0
        private void BindAutomobilesGrid()
        {
            object sortDirectionObj             = ViewState[CarServiceConstants.SORT_DIRECTION_VIEW_STATE_ATTR];
            object sortExpressionObj            = ViewState[CarServiceConstants.SORT_EXPRESSION_VIEW_STATE_ATTR];
            IQueryable <Automobile> automobiles = this.persister.GetAutomobiles();
            IQueryable <Automobile> sortedAutomobiles;

            if (sortDirectionObj != null && sortExpressionObj != null)
            {
                sortedAutomobiles = SortingUtility.SortAutomobiles(automobiles, sortExpressionObj.ToString(),
                                                                   (SortDirection)sortDirectionObj);
            }
            else
            {
                ViewState[CarServiceConstants.SORT_DIRECTION_VIEW_STATE_ATTR]  = SortDirection.Ascending;
                ViewState[CarServiceConstants.SORT_EXPRESSION_VIEW_STATE_ATTR] = CarServiceConstants.AUTOMOBILE_ID_SORT_EXPRESSION;
                sortedAutomobiles = automobiles;
            }
            BindAutomobilesGrid(sortedAutomobiles);
        }