Exemple #1
0
        public override Expr ToExpression()
        {
            if (this.Category == IntegerFilterCategory.NoFilter)
            {
                return(null);
            }
            else if (this.Category == IntegerFilterCategory.IsNull)
            {
                return(this.CreateIsNullExpr());
            }
            else if (this.Category == IntegerFilterCategory.IsNotNull)
            {
                return(this.CreateIsNullExpr());
            }
            else if (this.Category == IntegerFilterCategory.IsInRange)
            {
                var expr_and = new ExprLogicalAnd();
                if (this.range.UpperBound.HasValue)
                {
                    var op           = ComparisonOperation.LesserThanOrEquals;
                    var expr_compare = Expr.GetExprComparison(this.expr_field, new ExprLiteralInt(this.range.UpperBound.Value), op);
                    expr_and.Add(expr_compare);
                }

                if (this.range.LowerBound.HasValue)
                {
                    var op           = ComparisonOperation.GreaterThanOrEquals;
                    var expr_compare = Expr.GetExprComparison(this.expr_field, new ExprLiteralInt(this.range.UpperBound.Value), op);
                    expr_and.Add(expr_compare);
                }

                return(expr_and);
            }
            else if (this.Category == IntegerFilterCategory.IsOneOf)
            {
                var expr_or = new ExprLogicalOr();
                foreach (var item in this.one_of_list)
                {
                    var expr2        = new ExprLiteralInt(item);
                    var expr_compare = Expr.GetExprComparison(this.expr_field, expr2, AdlClient.OData.Models.ComparisonOperation.Equals);
                    expr_or.Add(expr_compare);
                }
                return(expr_or);
            }
            else
            {
                string msg = string.Format("Unhandled datetime integer category: \"{0}\"", this.Category);
                throw new System.ArgumentException(msg);
            }
        }
Exemple #2
0
        public override Expr ToExpression()
        {
            if (this.Category == EnumFilterCategory.NoFilter)
            {
                return(null);
            }
            else if (this.Category == EnumFilterCategory.IsNull)
            {
                return(this.CreateIsNullExpr());
            }
            else if (this.Category == EnumFilterCategory.IsNotNull)
            {
                return(this.CreateIsNotNullExpr());
            }
            else if (this.Category == EnumFilterCategory.IsOneOf)
            {
                var expr_or = new ExprLogicalOr();
                foreach (var item in this.one_of_value)
                {
                    var    t_value        = (T)item;
                    string t_string_value = t_value.ToString();
                    var    expr_t         = new ExprLiteralString(t_string_value);
                    var    expr_compare   = Expr.GetExprComparison(this.expr_field, expr_t, ComparisonOperation.Equals);
                    expr_or.Add(expr_compare);
                }

                if (this.Not)
                {
                    var expr_not = new ExprLogicalNot(expr_or);
                    return(expr_not);
                }
                else
                {
                    return(expr_or);
                }
            }
            else
            {
                string msg = string.Format("Unhandled datetime enum category: \"{0}\"", this.Category);
                throw new System.ArgumentException(msg);
            }
        }
Exemple #3
0
        public override Expr ToExpression()
        {
            if (this.Category == StringFilterCategory.IsOneOf && this.values != null && this.values.Count > 0)
            {
                var expr_or = new ExprLogicalOr();
                foreach (var item in this.values)
                {
                    var expr1        = FieldFilterString.AlterCase(this.expr_field, this.IgnoreCase);
                    var expr2        = FieldFilterString.AlterCase(new ExprLiteralString(item), this.IgnoreCase);
                    var expr_compare = Expr.GetExprComparison(expr1, expr2, AdlClient.OData.Models.ComparisonOperation.Equals);
                    expr_or.Add(expr_compare);
                }
                return(expr_or);
            }
            else if (this.Category == StringFilterCategory.Contains && this.values != null)
            {
                var expr_or = new ExprLogicalOr();

                foreach (var item in this.values)
                {
                    var expr_1 = FieldFilterString.AlterCase(new ExprLiteralString(item), this.IgnoreCase);
                    var expr_2 = FieldFilterString.AlterCase(this.expr_field, this.IgnoreCase);

                    var expr_substringof = new ExprSubstringOf(expr_1, expr_2);

                    expr_or.Add(expr_substringof);
                }
                return(expr_or);
            }
            else if (this.Category == StringFilterCategory.EndWith && this.values != null)
            {
                var expr_or = new ExprLogicalOr();

                foreach (var item in this.values)
                {
                    var expr_1 = FieldFilterString.AlterCase(this.expr_field, this.IgnoreCase);
                    var expr_2 = FieldFilterString.AlterCase(new ExprLiteralString(item), this.IgnoreCase);

                    var expr_endswith = new ExprEndsWith(expr_1, expr_2);

                    expr_or.Add(expr_endswith);
                }
                return(expr_or);
            }
            else if (this.Category == StringFilterCategory.BeginsWith && this.values != null)
            {
                var expr_or = new ExprLogicalOr();

                foreach (var item in this.values)
                {
                    var expr_1 = FieldFilterString.AlterCase(this.expr_field, this.IgnoreCase);
                    var expr_2 = FieldFilterString.AlterCase(new ExprLiteralString(item), this.IgnoreCase);

                    var expr_startswith = new ExprStartsWith(expr_1, expr_2);

                    expr_or.Add(expr_startswith);
                }
                return(expr_or);
            }
            else if (this.Category == StringFilterCategory.NoFilter)
            {
                return(null);
            }
            else if (this.Category == StringFilterCategory.IsNotNull)
            {
                return(this.CreateIsNotNullExpr());
            }
            else if (this.Category == StringFilterCategory.IsNull)
            {
                return(this.CreateIsNullExpr());
            }
            else
            {
                string msg = string.Format("Unhandled string filter category: \"{0}\"", this.Category);
                throw new System.ArgumentException(msg);
            }
        }