コード例 #1
0
        private Expression <Func <PreFilterTotal <T>, bool> > IndividualPropertySearch(DataTableRequest request)
        {
            var        paramExpression    = Expression.Parameter(typeof(PreFilterTotal <T>), "val");
            Expression compoundExpression = Expression.Constant(true);

            foreach (var dataTableColumn in request.Columns)
            {
                var query = dataTableColumn.SearchTerm;

                if (string.IsNullOrEmpty(query))
                {
                    continue;
                }

                var searchColumn = dataTableColumn.ColumnIndex;
                if (searchColumn < 0 || searchColumn >= properties.Length)
                {
                    continue;
                }

                var propertyToSearch = properties[searchColumn];
                if (!searchableProperties.Contains(propertyToSearch))
                {
                    continue;
                }

                var expression = ParseFactory.GetParser(query, propertyToSearch, paramExpression).GetSearchExpression();
                compoundExpression = Expression.And(compoundExpression, expression);
            }
            var result = Expression.Lambda <Func <PreFilterTotal <T>, bool> >(compoundExpression, paramExpression);

            return(result);
        }
コード例 #2
0
 private IEnumerable <Expression> GetSearchQueries(string searchExpression, ParameterExpression paramExpression)
 {
     return(properties.Where(x => searchableProperties.Contains(x)).Select(property => ParseFactory.GetParser(searchExpression, property, paramExpression).GetSearchExpression()));
 }