Example #1
0
        private void StringIsNullOrEmpty4()
        {
            WhereConst.name = "xx";
            Expression <Func <Student, bool> > exp        = it => 2 == it.Id || SqlFunc.IsNullOrEmpty(WhereConst.name);;
            OracleExpressionContext            expContext = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.WhereSingle);
            var value = expContext.Result.GetString();
            var pars  = expContext.Parameters;

            base.Check(value, pars, "(( :Id0 = \"ID\" ) OR ( :MethodConst1='' OR :MethodConst1 IS NULL ))", new List <SugarParameter>()
            {
                new SugarParameter(":MethodConst1", "xx"),
                new SugarParameter(":Id0", 2)
            }, "StringIsNullOrEmpty4 error");
        }
Example #2
0
        private void single3(int p = 1)
        {
            Expression <Func <Student, object> > exp = it => new DataTestInfo()
            {
                Datetime1 = DateTime.Now, String = it.Name
            };
            OracleExpressionContext expContext = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.SelectSingle);
            var selectorValue = expContext.Result.GetString();
            var pars          = expContext.Parameters;

            base.Check(
                @"  :CONSTANT0 AS ""DATETIME1"" , ""NAME"" AS ""STRING"" ", null, selectorValue, null,
                "Select.single3 Error");
        }
Example #3
0
        private void whereSingle4()
        {
            Expression <Func <Student, bool> > exp        = it => (it.Id > 1 && it.Name != "a") || it.Name == "a1";
            OracleExpressionContext            expContext = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.WhereSingle);
            var value = expContext.Result.GetString();
            var pars  = expContext.Parameters;

            base.Check(value, pars, " ((( \"Id\" > :Id0 ) AND ( \"Name\" <> :Name1 )) OR ( \"Name\" = :Name2 ))  ", new List <SugarParameter>()
            {
                new SugarParameter(":Id0", 1),
                new SugarParameter(":Name1", "a"),
                new SugarParameter(":Name2", "a1")
            }, "whereSingle4");
        }
Example #4
0
        private void whereSingle16()
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("key", "x1");
            Expression <Func <DataTestInfo, bool> > exp = it => it.String == dic["key"];
            OracleExpressionContext expContext          = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.WhereSingle);
            var value = expContext.Result.GetString();
            var pars  = expContext.Parameters;

            base.Check(value, pars, "( \"String\" = :Const0 )", new List <SugarParameter>()
            {
                new SugarParameter(":Const0", dic["key"])
            }, "whereSingle16");
        }
Example #5
0
        private void IIF2()
        {
            Expression <Func <Student, bool> > exp        = it => SqlFunc.IIF(SqlFunc.Contains(it.Name, "a"), 1, 2) == 1;
            OracleExpressionContext            expContext = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.WhereSingle);
            var value = expContext.Result.GetString();
            var pars  = expContext.Parameters;

            base.Check(value, pars, "(( CASE  WHEN  (\"NAME\" like '%'||:MethodConst0||'%')  THEN :MethodConst1  ELSE :MethodConst2 END ) = :Const3 )", new List <SugarParameter>()
            {
                new SugarParameter(":MethodConst0", "a"),
                new SugarParameter(":MethodConst1", 1),
                new SugarParameter(":MethodConst2", 2),
                new SugarParameter(":Const3", 1)
            }, "IIF2 error");
        }
Example #6
0
        private void IIF()
        {
            Expression <Func <Student, bool> > exp        = it => SqlFunc.IIF(it.Id == 1, 1, 2) == 1;
            OracleExpressionContext            expContext = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.WhereSingle);
            var value = expContext.Result.GetString();
            var pars  = expContext.Parameters;

            base.Check(value, pars, "(( CASE  WHEN ( \"ID\" = :Id0 ) THEN :MethodConst1  ELSE :MethodConst2 END ) = :Const3 )", new List <SugarParameter>()
            {
                new SugarParameter(":Id0", 1),
                new SugarParameter(":MethodConst1", 1),
                new SugarParameter(":MethodConst2", 2),
                new SugarParameter(":Const3", 1)
            }, "IIF error");
        }
Example #7
0
        private void DateAddByType()
        {
            var x2 = DateTime.Now;
            Expression <Func <Student, bool> > exp        = it => SqlFunc.DateAdd(x2, 11, DateType.Millisecond) == x2;
            OracleExpressionContext            expContext = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.WhereSingle);
            var value = expContext.Result.GetString();
            var pars  = expContext.Parameters;

            base.Check(value, pars, "((:MethodConst0+(1.15740740740741E-08*:MethodConst1)) = :Const3 )", new List <SugarParameter>()
            {
                new SugarParameter(":Const3", x2),
                new SugarParameter(":MethodConst0", x2),
                new SugarParameter(":MethodConst1", 11)
            }, "DateAddByType error");
        }
Example #8
0
        private void Length()
        {
            Expression <Func <Student, bool> > exp        = it => SqlFunc.Length("aaaa") > 1;
            OracleExpressionContext            expContext = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.WhereSingle);
            var value = expContext.Result.GetString();
            var pars  = expContext.Parameters;

            base.Check(value, pars, "(LENGTH(:MethodConst0) > :Const1 )", new List <SugarParameter>()
            {
                new SugarParameter(":MethodConst0", "aaaa"), new SugarParameter(":Const1", 1)
            }, "Length error");

            Length2();
            Length3();
        }
Example #9
0
        private void single5()
        {
            var p = (DateTime?)DateTime.Now;
            Expression <Func <Student, object> > exp = it => p.HasValue;
            OracleExpressionContext expContext       = new OracleExpressionContext();

            expContext.IsSingle = false;
            expContext.Resolve(exp, ResolveExpressType.WhereMultiple);
            var selectorValue = expContext.Result.GetString();
            var pars          = expContext.Parameters;

            base.Check(
                @"( :constant0<>'' AND :constant0 IS NOT NULL )", new List <SugarParameter>()
            {
                new SugarParameter(":constant0", p)
            }, selectorValue, pars,
                "Select.single4 Error");
        }
Example #10
0
        private void WhereMultiple2()
        {
            string name = "a";

            WhereConst.name = "a1";
            Expression <Func <Student, bool> > exp        = it => (it.Id > 1 && it.Name != name || it.Id == 1) || it.Name == WhereConst.name;
            OracleExpressionContext            expContext = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.WhereMultiple);
            var value = expContext.Result.GetString();
            var pars  = expContext.Parameters;

            base.Check(value, pars, " (((( \"it\".\"Id\" > :Id0 ) AND ( \"it\".\"Name\" <> :Name1 )) OR ( \"it\".\"Id\" = :Id2 )) OR ( \"it\".\"Name\" = :Name3 ))", new List <SugarParameter>()
            {
                new SugarParameter(":Id0", 1),
                new SugarParameter(":Name1", "a"),
                new SugarParameter(":Id2", 1),
                new SugarParameter(":Name3", "a1")
            }, "WhereMultiple2");
        }
Example #11
0
        private void MultipleDynamic()
        {
            Expression <Func <Student, School, object> > exp = (it, school) => new { Name = "a", Id = it.Id / 2, SchoolId = school.Id };
            OracleExpressionContext expContext = new OracleExpressionContext();

            expContext.IsSingle = false;
            expContext.Resolve(exp, ResolveExpressType.SelectMultiple);
            var selectorValue = expContext.Result.GetString();
            var pars          = expContext.Parameters;

            base.Check(
                selectorValue,
                pars,
                @" :CONSTANT0 AS ""NAME"" , ( ""IT"".""ID"" / :ID1 ) AS ""ID"" , ""SCHOOL"".""ID"" AS ""SCHOOLID""  ",
                new List <SugarParameter>()
            {
                new SugarParameter(":constant0", "a"),
                new SugarParameter(":Id1", 2)
            },
                "Select.MultipleDynamic Error");
        }
Example #12
0
        private void Multiple2()
        {
            Expression <Func <Student, School, object> > exp = (it, school) => new ViewModelStudent3()
            {
                SchoolName = school.Name, Id = SqlFunc.GetSelfAndAutoFill(it.Id)
            };
            OracleExpressionContext expContext = new OracleExpressionContext();

            expContext.IsSingle = false;
            expContext.Resolve(exp, ResolveExpressType.SelectMultiple);
            var selectorValue = expContext.Result.GetString();
            var pars          = expContext.Parameters;

            base.Check(
                selectorValue,
                pars,
                @" ""SCHOOL"".""NAME"" AS ""SCHOOLNAME"" ,it.*",
                new List <SugarParameter>()
            {
            },
                "Select.Multiple Error");
        }
Example #13
0
        private void singleDynamic()
        {
            string a = "a";
            Expression <Func <Student, object> > exp = it => new { x = it.Id, shoolid = 1, name = a, p = it.Id * 2 };
            OracleExpressionContext expContext       = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.SelectSingle);
            var selectorValue = expContext.Result.GetString();
            var pars          = expContext.Parameters;

            base.Check(
                selectorValue,
                pars,
                @" ""ID"" AS ""X"" , :CONSTANT0 AS ""SHOOLID"" , :CONSTANT1 AS ""NAME"" , ( ""ID"" * :ID2 ) AS ""P"" ",
                new List <SugarParameter>()
            {
                new SugarParameter(":constant0", 1),
                new SugarParameter(":constant1", "a"),
                new SugarParameter(":Id2", 2)
            },
                "Select.singleDynamic Error");
        }
Example #14
0
        private void single2(int p = 1)
        {
            Expression <Func <Student, object> > exp = it => new Student()
            {
                Name = "a", Id = it.Id, SchoolId = p, TestId = it.Id + 11
            };
            OracleExpressionContext expContext = new OracleExpressionContext();

            expContext.Resolve(exp, ResolveExpressType.SelectSingle);
            var selectorValue = expContext.Result.GetString();
            var pars          = expContext.Parameters;

            base.Check(
                selectorValue,
                pars,
                @" :CONSTANT0 AS ""NAME"" , ""ID"" AS ""ID"" , :CONSTANT1 AS ""SCHOOLID"" , ( ""ID"" + :ID2 ) AS ""TESTID""  ",
                new List <SugarParameter>()
            {
                new SugarParameter(":constant0", "a"),
                new SugarParameter(":constant1", 1),
                new SugarParameter(":Id2", 11)
            },
                "Select.single Error");
        }
Example #15
0
        private void Multiple()
        {
            Expression <Func <Student, School, object> > exp = (it, school) => new Student()
            {
                Name = "a", Id = it.Id, SchoolId = school.Id, TestId = it.Id + 1
            };
            OracleExpressionContext expContext = new OracleExpressionContext();

            expContext.IsSingle = false;
            expContext.Resolve(exp, ResolveExpressType.SelectMultiple);
            var selectorValue = expContext.Result.GetString();
            var pars          = expContext.Parameters;

            base.Check(
                selectorValue,
                pars,
                @"  @constant0 AS ""Name"" , ""it"".""Id"" AS ""Id"" , ""school"".""Id"" AS ""SchoolId"" , ( ""it"".""Id"" + @Id1 ) AS ""TestId"" ",
                new List <SugarParameter>()
            {
                new SugarParameter("@constant0", "a"),
                new SugarParameter("@Id1", 1)
            },
                "Select.Multiple Error");
        }