示例#1
0
 public FilterGroup(FilterGroupOperation groupOperation, QueryToken?token, List <Filter> filters)
 {
     this.GroupOperation = groupOperation;
     this.Token          = token;
     this.Filters        = filters;
 }
 public QueryFilterGroup(FilterGroupOperation operation)
 {
     Operation = operation;
 }
 public QueryFilterGroup(FilterGroupOperation operation, QueryFilterElement[] filterElements)
 {
     Operation      = operation;
     FilterElements = filterElements;
 }
示例#4
0
        private static Expression GetFilterGroupExpression <T>(IList <QueryFilter> filters, ParameterExpression param, FilterGroupOperation operation = FilterGroupOperation.And)
        {
            Expression expression = null;

            foreach (QueryFilter filter in filters)
            {
                Expression subExpression = null;
                if (filter is QueryFilterGroup filterGroup)
                {
                    subExpression = GetFilterGroupExpression <T>(filterGroup.FilterElements, param, operation);
                }
                else
                {
                    subExpression = GetFilterElementExpression <T>((QueryFilterElement)filter, param);
                }

                switch (operation)
                {
                case FilterGroupOperation.And:
                    expression = expression == null ? subExpression : Expression.AndAlso(expression, subExpression);
                    break;

                case FilterGroupOperation.Or:
                    expression = expression == null ? subExpression : Expression.OrElse(expression, subExpression);
                    break;

                default: throw new ArgumentOutOfRangeException();
                }
            }

            return(expression);
        }