コード例 #1
0
ファイル: Filter.cs プロジェクト: zeevir/framework
 public FilterGroup(FilterGroupOperation groupOperation, QueryToken?token, List <Filter> filters)
 {
     this.GroupOperation = groupOperation;
     this.Token          = token;
     this.Filters        = filters;
 }
コード例 #2
0
 public QueryFilterGroup(FilterGroupOperation operation)
 {
     Operation = operation;
 }
コード例 #3
0
 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);
        }