コード例 #1
0
        public Expression <Func <TEntity, bool> > GetGridExpression(BaseGrid <TEntity> grid)
        {
            var expression = PredicateHelper.True <TEntity>();

            var customFilterExpression = grid.GetCustomFilterExpression();

            if (customFilterExpression != null)
            {
                expression = expression.And(customFilterExpression);
            }

            var searchExpression = grid.GetSearchExpression();

            if (searchExpression != null)
            {
                expression = expression.And(searchExpression);
            }

            foreach (var filter in grid.Filters.Where(q => q.HasSelectedData))
            {
                var filterExpression = _filterStore.FilterExpressionGeneratorStrategies[filter.Type].GetFilterLinqExpression(filter);
                if (filterExpression != null)
                {
                    expression = expression.And(filterExpression);
                }
            }

            return(expression);
        }