コード例 #1
0
        private static Expression <Func <T, bool> > GetGroupExpression <T>(DataFilterGroup paramGroup, DataFilter <T> filter)
            where T : BaseModel
        {
            bool startParam = !(paramGroup.Type == FilterGroupType.Or &&
                                (paramGroup.ParamGroupList.Any() || paramGroup.ParamList.Any()));
            Expression <Func <T, bool> > expressions = PredicateBuilder.New <T>(startParam);

            paramGroup.ParamList.ForEach(param =>
            {
                Expression <Func <T, bool> > expression;

                DataFilterQueryExpression <T> customExpression = filter.CustomQueryExpressionList.FirstOrDefault(x => x.Field == param.Field);
                if (customExpression != null)
                {
                    expression = customExpression.Expression;
                }
                else
                {
                    expression = FilterExpressionProvider.CreateExpression <T>(param);
                }


                expressions = IncludeExpression(expressions, expression, paramGroup.Type);
            });

            paramGroup.ParamGroupList.ForEach(group =>
            {
                Expression <Func <T, bool> > expression = GetGroupExpression <T>(group, filter);
                expressions = IncludeExpression(expressions, expression, paramGroup.Type);
            });


            return(expressions);
        }
コード例 #2
0
ファイル: DataFilter.cs プロジェクト: will-steffen/esof-tcc
        public DataFilter <TModel> AddCustomQueryExpression(string field, Expression <Func <TModel, bool> > expression)
        {
            DataFilterQueryExpression <TModel> expr = new DataFilterQueryExpression <TModel>
            {
                Field      = field,
                Expression = expression
            };

            CustomQueryExpressionList.Add(expr);
            return(this);
        }