Exemplo n.º 1
0
        public void Double_Boolean_Expression_Test()
        {
            Expression <Func <Entity, bool> > where = x => x.Active || x.Enabled;
            var whereClause = WhereVisitor <Entity> .CreateModel(where.Body);

            whereClause.LeftOperand.Type.ShouldEqual(Operand.OperandType.Operator);

            whereClause.LeftOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);

            whereClause.LeftOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Equal);

            whereClause.LeftOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.LeftOperand.Operator.RightOperand.Projection.Constant.Value.ShouldEqual(true);

            whereClause.Type.ShouldEqual(Operator.OperatorType.Or);

            whereClause.RightOperand.Type.ShouldEqual(Operand.OperandType.Operator);

            whereClause.RightOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);

            whereClause.RightOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Equal);

            whereClause.RightOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.RightOperand.Operator.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.RightOperand.Operator.RightOperand.Projection.Constant.Value.ShouldEqual(true);
        }
Exemplo n.º 2
0
        public void Null_Test()
        {
            Expression <Func <Entity, bool> > expression = x => x.Flag == null;
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(0);
            statement.Text.ShouldEqual("([flag] IS NULL)");
        }
Exemplo n.º 3
0
        public void Equals_Boolean_Expression_Test()
        {
            Expression <Func <Entity, bool> > expression = x => x.Active == (x.Age == 33);
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(1);
            statement.Parameters.First().Value.ShouldEqual(33);
            statement.Text.ShouldEqual(string.Format("([active] = CASE WHEN ([age] = @{0}) THEN 1 ELSE 0 END)", statement.Parameters.First().Key));
        }
Exemplo n.º 4
0
        public void should_generate_sql_for_not_contains()
        {
            Expression <Func <Entity, bool> > expression = x => !x.Name.Contains("ed");
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(1);
            statement.Parameters.First().Value.ShouldEqual("ed");
            statement.Text.ShouldEqual(string.Format("([name] NOT LIKE '%' + @{0} + '%')", statement.Parameters.First().Key));
        }
Exemplo n.º 5
0
        public void Less_Than_Or_Equal_Test()
        {
            Expression <Func <Entity, bool> > expression = x => x.Age <= 33;
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(1);
            statement.Parameters.First().Value.ShouldEqual(33);
            statement.Text.ShouldEqual(string.Format("([age] <= @{0})", statement.Parameters.First().Key));
        }
Exemplo n.º 6
0
        public void should_generate_sql_for_ends_with_equals_false()
        {
            Expression <Func <Entity, bool> > expression = x => x.Name.EndsWith("ed") == false;
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(1);
            statement.Parameters.First().Value.ShouldEqual("ed");
            statement.Text.ShouldEqual(string.Format("([name] NOT LIKE '%' + @{0})", statement.Parameters.First().Key));
        }
Exemplo n.º 7
0
        public void should_generate_sql_for_trim()
        {
            Expression <Func <Entity, bool> > expression = x => x.Name.Trim() == "ed";
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(1);
            statement.Parameters.First().Value.ShouldEqual("ed");
            statement.Text.ShouldEqual(string.Format("(LTRIM(RTRIM([name])) = @{0})", statement.Parameters.First().Key));
        }
Exemplo n.º 8
0
        public void Or_Test()
        {
            Expression <Func <Entity, bool> > expression = x => x.Age == 10 || x.Flag != null;
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(1);
            statement.Parameters.First().Value.ShouldEqual(10);
            statement.Text.ShouldEqual($"(([age] = @{statement.Parameters.First().Key}) OR ([flag] IS NOT NULL))");
        }
Exemplo n.º 9
0
        public void Unary_True_Test()
        {
            Expression <Func <Entity, bool> > expression = x => x.Active;
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(1);
            statement.Parameters.First().Value.ShouldEqual(true);
            statement.Text.ShouldEqual(string.Format("([active] = @{0})", statement.Parameters.First().Key));
        }
Exemplo n.º 10
0
        public void should_not_cast_dynamic_value()
        {
            var optout = (object)true;
            Expression <Func <Entity, bool> > expression = x => x.Values["optout"] == optout;
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(1);
            statement.Parameters.First().Value.ShouldEqual(true);
            statement.Text.ShouldEqual(string.Format("([optout] = @{0})", statement.Parameters.First().Key));
        }
Exemplo n.º 11
0
        public void Modulo_Test()
        {
            Expression <Func <Entity, bool> > expression = x => x.Age % 20 == 55;
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(2);
            statement.Parameters.First().Value.ShouldEqual(20);
            statement.Parameters.Skip(1).First().Value.ShouldEqual(55);
            statement.Text.ShouldEqual(string.Format("(([age] % @{0}) = @{1})", statement.Parameters.First().Key, statement.Parameters.Skip(1).First().Key));
        }
Exemplo n.º 12
0
        public void Not_Bool_Test()
        {
            Expression <Func <Entity, bool> > expression = x => !x.Active && !(bool)x.Values["optout"];
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(2);
            statement.Parameters.First().Value.ShouldEqual(false);
            statement.Parameters.Skip(1).First().Value.ShouldEqual(false);
            statement.Text.ShouldEqual(string.Format("(([active] = @{0}) AND (CAST([optout] AS bit) = @{1}))",
                                                     statement.Parameters.First().Key,
                                                     statement.Parameters.Skip(1).First().Key));
        }
Exemplo n.º 13
0
        public void Not_Expression_Test()
        {
            Expression <Func <Entity, bool> > expression = x => !(x.Age == 33);
            var statement = WhereWriter <Entity> .CreateStatement(WhereVisitor <Entity> .CreateModel(expression.Body), Map);

            statement.Parameters.Count().ShouldEqual(2);
            statement.Parameters.First().Value.ShouldEqual(33);
            statement.Parameters.Skip(1).First().Value.ShouldEqual(false);
            statement.Text.ShouldEqual(string.Format("(CASE WHEN ([age] = @{0}) THEN 1 ELSE 0 END = @{1})",
                                                     statement.Parameters.First().Key,
                                                     statement.Parameters.Skip(1).First().Key));
        }
Exemplo n.º 14
0
        public void Equals_Constant_Test()
        {
            Expression <Func <Entity, bool> > where = x => x.Name == "Jeff";

            var whereClause = WhereVisitor <Entity> .CreateModel(where.Body);

            whereClause.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);

            whereClause.Type.ShouldEqual(Operator.OperatorType.Equal);

            whereClause.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
        }
Exemplo n.º 15
0
        public void Equals_Boolean_Not_Equals_Test()
        {
            Expression <Func <Entity, bool> > where = x => x.Active == false;

            var whereClause = WhereVisitor <Entity> .CreateModel(where.Body);

            whereClause.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);

            whereClause.Type.ShouldEqual(Operator.OperatorType.Equal);

            whereClause.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
        }
Exemplo n.º 16
0
        public void Method_Boolean_Not_Expression_Test()
        {
            Expression <Func <Entity, bool> > where = x => !x.Name.Contains("t");
            var whereClause = WhereVisitor <Entity> .CreateModel(where.Body);

            whereClause.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);

            whereClause.Type.ShouldEqual(Operator.OperatorType.Equal);

            whereClause.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.RightOperand.Projection.Constant.Value.ShouldEqual(false);
        }
Exemplo n.º 17
0
        public void Not_Boolean_Object_Dictionary_Expression_Test()
        {
            Expression <Func <Entity, bool> > where = x => !(bool)x.Values["Disabled"];
            var whereClause = WhereVisitor <Entity> .CreateModel(where.Body);

            whereClause.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);

            whereClause.Type.ShouldEqual(Operator.OperatorType.Equal);

            whereClause.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.RightOperand.Projection.Constant.Value.ShouldEqual(false);
        }
Exemplo n.º 18
0
        public void Equals_Entity_Property_Test()
        {
            var entity = new Entity {
                Name = "yada"
            };

            Expression <Func <Entity, bool> > where = x => x.Name == entity.Name;

            var whereClause = WhereVisitor <Entity> .CreateModel(where.Body);

            whereClause.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Field);

            whereClause.Type.ShouldEqual(Operator.OperatorType.Equal);

            whereClause.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
        }
Exemplo n.º 19
0
 public void Delete(Expression <Func <TEntity, bool> > filter)
 {
     Delete(WhereVisitor <TEntity> .CreateModel(filter), false);
 }
Exemplo n.º 20
0
        public void Complex_Test()
        {
            var number1 = 45;
            var someKey = "OptOut";

            Expression <Func <Entity, bool> > where = x => ((!((x.Name ?? x.NickName) == "Jeff") && x.Age > AddValues(number1, "yada".Length)) || x.Name.Contains(x.NickName) && !(bool)x.Values[someKey]) == x.Flags["Bounce"] || x.Name.Substring(x.NickName.IndexOf("yada"), x.NickName.Length) == "yada";

            //                  Coalesce(x.Name, x.NickName)
            //                  ==
            //                  "Jeff"
            //             ==
            //                  false
            //          &&
            //              x.Price > 49
            //      ||
            //              Contains(Name, NickName)
            //              ==
            //              true
            //         &&
            //              Convert(someKey, bool) == false
            //      ==
            //      Bounce
            // ||
            //         Substring(
            //            Name,
            //            IndexOf(
            //                NickName,
            //                "yada"),
            //            Length(NickName))
            //         ==
            //              "yada";

            var whereClause = WhereVisitor <Entity> .CreateModel(where.Body);

            whereClause.LeftOperand.Type.ShouldEqual(Operand.OperandType.Operator);

            whereClause.LeftOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Operator);

            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Function);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Type.ShouldEqual(Function.FunctionType.Coalesce);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Coalesce.First.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Coalesce.First.Field.Name.ShouldEqual("Name");
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Coalesce.First.Field.HasKey.ShouldEqual(false);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Coalesce.Second.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Coalesce.Second.Field.Name.ShouldEqual("NickName");
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Coalesce.Second.Field.HasKey.ShouldEqual(false);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Operator);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Equal);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Projection.Constant.Value.ShouldEqual("Jeff");

            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Operator);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Equal);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Projection.Constant.Value.ShouldEqual(false);

            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Operator);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.Type.ShouldEqual(Operator.OperatorType.And);

            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Operator);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Field.Name.ShouldEqual("Age");
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Field.HasKey.ShouldEqual(false);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.Type.ShouldEqual(Operator.OperatorType.GreaterThan);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Projection.Constant.Value.ShouldEqual(49);

            whereClause.LeftOperand.Operator.LeftOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Or);

            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Function);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Type.ShouldEqual(Function.FunctionType.Contains);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Contains.Text.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Contains.Text.Field.Name.ShouldEqual("Name");
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Contains.Value.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.LeftOperand.Projection.Function.Contains.Value.Field.Name.ShouldEqual("NickName");
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Operator);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Equal);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.LeftOperand.Operator.RightOperand.Projection.Constant.Value.ShouldEqual(true);

            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Operator);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.Type.ShouldEqual(Operator.OperatorType.And);

            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Operator);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Equal);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Function);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Function.Type.ShouldEqual(Function.FunctionType.Convert);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Function.Convert.Value.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Function.Convert.Value.Field.Name.ShouldEqual("Values");
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Function.Convert.Value.Field.HasKey.ShouldEqual(true);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Function.Convert.Value.Field.Key.ShouldEqual("OptOut");
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.LeftOperand.Projection.Function.Convert.Type.ShouldEqual(typeof(bool));
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Equal);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.LeftOperand.Operator.LeftOperand.Operator.RightOperand.Operator.RightOperand.Operator.RightOperand.Projection.Constant.Value.ShouldEqual(false);

            whereClause.LeftOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Equal);

            whereClause.LeftOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.LeftOperand.Operator.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.LeftOperand.Operator.RightOperand.Projection.Field.Name.ShouldEqual("Flags");
            whereClause.LeftOperand.Operator.RightOperand.Projection.Field.HasKey.ShouldEqual(true);
            whereClause.LeftOperand.Operator.RightOperand.Projection.Field.Key.ShouldEqual("Bounce");

            whereClause.Type.ShouldEqual(Operator.OperatorType.Or);

            whereClause.RightOperand.Type.ShouldEqual(Operand.OperandType.Operator);
            whereClause.RightOperand.Operator.LeftOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Function);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.Type.ShouldEqual(Function.FunctionType.SubstringFixed);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Text.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Text.Field.Name.ShouldEqual("Name");
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Text.Field.HasKey.ShouldEqual(false);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Start.Type.ShouldEqual(Projection.ProjectionType.Function);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Start.Function.Type.ShouldEqual(Function.FunctionType.IndexOf);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Start.Function.IndexOf.Text.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Start.Function.IndexOf.Text.Field.Name.ShouldEqual("NickName");
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Start.Function.IndexOf.Text.Field.HasKey.ShouldEqual(false);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Start.Function.IndexOf.Value.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Start.Function.IndexOf.Value.Constant.Value.ShouldEqual("yada");
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Length.Type.ShouldEqual(Projection.ProjectionType.Function);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Length.Function.Type.ShouldEqual(Function.FunctionType.Length);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Length.Function.Length.Text.Type.ShouldEqual(Projection.ProjectionType.Field);
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Length.Function.Length.Text.Field.Name.ShouldEqual("NickName");
            whereClause.RightOperand.Operator.LeftOperand.Projection.Function.SubstringFixed.Length.Function.Length.Text.Field.HasKey.ShouldEqual(false);
            whereClause.RightOperand.Operator.Type.ShouldEqual(Operator.OperatorType.Equal);
            whereClause.RightOperand.Operator.RightOperand.Type.ShouldEqual(Operand.OperandType.Projection);
            whereClause.RightOperand.Operator.RightOperand.Projection.Type.ShouldEqual(Projection.ProjectionType.Constant);
            whereClause.RightOperand.Operator.RightOperand.Projection.Constant.Value.ShouldEqual("yada");
        }
Exemplo n.º 21
0
 public int DeleteMany(Expression <Func <TEntity, bool> > filter)
 {
     return(Delete(WhereVisitor <TEntity> .CreateModel(filter), true));
 }