示例#1
0
        private void whereSingle20()
        {
            Expression <Func <DataTestInfo2, bool> > exp = it => it.Bool2.Value == it.Bool1;
            SqlServerExpressionContext expContext        = new SqlServerExpressionContext();

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

            base.Check(value, pars, "( [Bool2] = [Bool1] )", new List <SugarParameter>()
            {
            }, "whereSingle19");
        }
示例#2
0
        private void HasNumber()
        {
            Expression <Func <Student, bool> > exp        = it => SqlFunc.HasNumber(it.Id);
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "( [Id]>0 AND [Id] IS NOT NULL )", new List <SugarParameter>()
            {
            }, "HasNumber error");
        }
示例#3
0
        private void Length3()
        {
            Expression <Func <Student, bool> > exp        = it => it.Name.Length > "a".Length;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(LEN([Name])> @Length1 )", new List <SugarParameter>()
            {
                new SugarParameter("@Length1", 1)
            }, "Length3 error");
        }
示例#4
0
        private void whereSingle26()
        {
            var p = DateTime.Now;
            Expression <Func <DataTestInfo2, bool> > exp = it => it.Bool1 && it.Bool1;
            SqlServerExpressionContext expContext        = new SqlServerExpressionContext();

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

            base.Check(value, pars, "( ( [Bool1]=1 ) AND ( [Bool1]=1 ) )", new List <SugarParameter>()
            {
            }, "whereSingle26");
        }
示例#5
0
        private void whereSingle24()
        {
            Expression <Func <DataTestInfo, bool> > exp = it => it.Datetime1 > DateTime.Now.Date;
            SqlServerExpressionContext expContext       = new SqlServerExpressionContext();

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

            base.Check(value, pars, "( [Datetime1] > @Datetime10 )", new List <SugarParameter>()
            {
                new SugarParameter("@Datetime10", DateTime.Now.Date)
            }, "whereSingle24");
        }
示例#6
0
        private void whereSingle17()
        {
            Expression <Func <DataTestInfo, bool> > exp = it => true && it.String.Contains("a");
            SqlServerExpressionContext expContext       = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(( 1 = 1 ) AND ([String] like '%'+@MethodConst1+'%') )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst1", "a")
            }, "whereSingle17");
        }
示例#7
0
        private void ConvetToString()
        {
            Expression <Func <Student, bool> > exp        = it => Convert.ToString(it.Id) == "a";
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(CAST([Id] AS NVARCHAR(MAX)) = @Const0 )", new List <SugarParameter>()
            {
                new SugarParameter("@Const0", "a")
            }, "ConvetToString error");
        }
示例#8
0
        private void IIF5()
        {
            Expression <Func <DataTestInfo, bool> > exp = it => SqlFunc.IIF(true, Convert.ToBoolean(it.Datetime1), SqlFunc.ToBool(it.Datetime1)) == false;
            SqlServerExpressionContext expContext       = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(( CASE  WHEN ( 1 = 1 )  THEN  CAST([Datetime1] AS BIT)  ELSE  CAST([Datetime1] AS BIT) END ) = @Const0 )", new List <SugarParameter>()
            {
                new SugarParameter("@Const0", false)
            }, "IIF5 error");
        }
示例#9
0
        private void Contains2(string name = "a")
        {
            Expression <Func <Student, bool> > exp        = it => SqlFunc.Contains(it.Name, name);
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, " ([Name] like '%'+@MethodConst0+'%') ", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "a")
            }, "Contains2 error");
        }
示例#10
0
        private void Between()
        {
            Expression <Func <Student, bool> > exp        = it => SqlFunc.Between(it.Name, 1, 2);
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, " ([Name] BETWEEN @MethodConst0 AND @MethodConst1) ", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", 1), new SugarParameter("@MethodConst1", 2),
            }, "Between error");
        }
示例#11
0
        private void HasValue2(int p = 1)
        {
            Expression <Func <Student, bool> > exp        = it => it.CreateTime.HasValue;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(
                @"( [it].[CreateTime]<>'' AND [it].[CreateTime] IS NOT NULL )", null, selectorValue, null,
                "Select.HasValue2 Error");
        }
示例#12
0
        private void StringIsNullOrEmpty()
        {
            Expression <Func <Student, bool> > exp        = it => it.Id > 2 || SqlFunc.IsNullOrEmpty(it.Id);;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(( [Id] > @Id0 ) OR ( [Id]='' OR [Id] IS NULL ))", new List <SugarParameter>()
            {
                new SugarParameter("@Id0", 2)
            }, "StringIsNullOrEmpty error");
        }
示例#13
0
        private void Length()
        {
            Expression <Func <Student, bool> > exp        = it => SqlFunc.Length("aaaa") > 1;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(LEN(@MethodConst0) > @Const1 )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "aaaa"), new SugarParameter("@Const1", 1)
            }, "Length error");
        }
示例#14
0
        private void IIF4()
        {
            Expression <Func <DataTestInfo2, bool> > exp = it => SqlFunc.IIF(true, it.Bool1, it.Bool2) == true;
            SqlServerExpressionContext expContext        = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(( CASE  WHEN ( 1 = 1 )  THEN [Bool1]  ELSE [Bool2] END ) = @Const0 )", new List <SugarParameter>()
            {
                new SugarParameter("@Const0", true)
            }, "IIF4 error");
        }
示例#15
0
        private void MappingColumn()
        {
            Expression <Func <Student, bool> > exp        = it => SqlFunc.MappingColumn(it.Id, "Name") == 1;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(Name = @Const1 )", new List <SugarParameter>()
            {
                new SugarParameter("@Const1", 1)
            }, "MappingColumn error");
        }
示例#16
0
        private void Test1()
        {
            var ids = new int[] { 1, 2, 3 };
            Expression <Func <Student, bool> > exp        = it => ids.Contains(it.Id) && !SqlFunc.IsNullOrEmpty(it.Name);
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(([Id] IN ('1','2','3')) AND NOT( [Name]='' OR [Name] IS NULL ))", new List <SugarParameter>()
            {
            }, "Test1 error");
        }
示例#17
0
        private void Trim()
        {
            Expression <Func <Student, bool> > exp        = it => SqlFunc.Trim("  a") == it.Name;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "((rtrim(ltrim(@MethodConst0))) = [Name] )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "  a")
            }, "Trim error");
        }
示例#18
0
        private void ToLower()
        {
            Expression <Func <Student, bool> > exp        = it => "a" == SqlFunc.ToLower(it.Id);
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "( @Const0 = (LOWER([Id])) )", new List <SugarParameter>()
            {
                new SugarParameter("@Const0", "a")
            }, "ToLower error");
        }
示例#19
0
        private void DateIsSameByDay()
        {
            var x2 = DateTime.Now;
            Expression <Func <Student, bool> > exp        = it => SqlFunc.DateIsSame(x2, x2);
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(DATEDIFF(day,@MethodConst0,@MethodConst1)=0) ", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", x2), new SugarParameter("@MethodConst1", x2)
            }, "DateIsSameDay error");
        }
示例#20
0
        private void DateValue()
        {
            var x2 = DateTime.Now;
            Expression <Func <Student, bool> > exp        = it => SqlFunc.DateValue(x2, DateType.Year) == 1;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, " ((@MethodConst1(@MethodConst0)) = @Const2 ) ", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", x2), new SugarParameter("@MethodConst1", DateType.Year), new SugarParameter("@Const2", 1)
            }, "DateValue error");
        }
示例#21
0
        private void StringIsNullOrEmpty5()
        {
            WhereConst.name = "xx";
            Expression <Func <Student, bool> > exp        = it => !SqlFunc.IsNullOrEmpty(WhereConst.name);;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "NOT( @MethodConst0='' OR @MethodConst0 IS NULL )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "xx")
            }, "StringIsNullOrEmpty5 error");
        }
示例#22
0
        private void ToDouble()
        {
            var x2 = Guid.NewGuid();
            Expression <Func <Student, bool> > exp        = it => SqlFunc.ToDouble("2") == 2;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(CAST(@MethodConst0 AS FLOAT) = @Const1 )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "2"), new SugarParameter("@Const1", (Double)2)
            }, "ToDouble error");
        }
示例#23
0
        private void Time()
        {
            TimeSpan s = TimeSpan.Parse("11:22:22");
            Expression <Func <Student, bool> > exp        = it => SqlFunc.ToTime("11:12:59") == s;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(CAST(@MethodConst0 AS TIME) = @Const1 )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "11:12:59"), new SugarParameter("@Const1", s)
            }, "Time error");
        }
示例#24
0
        private void Replace()
        {
            var x2 = Guid.NewGuid();
            Expression <Func <Student, bool> > exp        = it => SqlFunc.Replace("aaaa", "a", "1") == "a";
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(REPLACE(@MethodConst0,@MethodConst1,@MethodConst2) = @Const3 )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "aaaa"), new SugarParameter("@MethodConst1", "a"), new SugarParameter("@MethodConst2", "1"), new SugarParameter("@Const3", "a")
            }, "Replace error");
        }
示例#25
0
        private void ToGuid()
        {
            var x2 = Guid.NewGuid();
            Expression <Func <Student, bool> > exp        = it => SqlFunc.ToGuid("A94027A3-476E-478D-8228-F4054394B874") == x2;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(CAST(@MethodConst0 AS UNIQUEIDENTIFIER) = @Const1 )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "A94027A3-476E-478D-8228-F4054394B874"), new SugarParameter("@Const1", x2)
            }, "ToGuid error");
        }
示例#26
0
        private void ExtendDate()
        {
            var x2 = DateTime.Now;
            Expression <Func <Student, bool> > exp        = it => Convert.ToDateTime("2015-1-1") == x2;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(CAST(@MethodConst0 AS DATETIME) = @Const1 )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "2015-1-1"), new SugarParameter("@Const1", x2)
            }, "ExtendDate error");
        }
示例#27
0
        private void StringIsNullOrEmpty2()
        {
            Expression <Func <Student, bool> > exp        = it => 2 == it.Id || SqlFunc.IsNullOrEmpty(true);;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

            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", true),
                new SugarParameter("@Id0", 2)
            }, "StringIsNullOrEmpty2 error");
        }
示例#28
0
        private void ToInt32()
        {
            var x2 = DateTime.Now;
            Expression <Func <Student, bool> > exp        = it => SqlFunc.ToInt32("3") == 1;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(CAST(@MethodConst0 AS INT) = @Const1 )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "3"), new SugarParameter("@Const1", 1)
            }, "ToInt32 error");
        }
示例#29
0
        private void ExtendSubstring()
        {
            var x2 = Guid.NewGuid();
            Expression <Func <Student, bool> > exp        = it => "aaaa".Substring(0, 2) == "a";
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "(SUBSTRING(@MethodConst0,1 + @MethodConst1,@MethodConst2) = @Const3 )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", "aaaa"), new SugarParameter("@MethodConst1", 0), new SugarParameter("@MethodConst2", 2), new SugarParameter("@Const3", "a")
            }, "Substring error");
        }
示例#30
0
        private void DateAddByType()
        {
            var x2 = DateTime.Now;
            Expression <Func <Student, bool> > exp        = it => SqlFunc.DateAdd(x2, 11, DateType.Millisecond) == x2;
            SqlServerExpressionContext         expContext = new SqlServerExpressionContext();

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

            base.Check(value, pars, "((DATEADD(Millisecond,@MethodConst1,@MethodConst0)) = @Const3 )", new List <SugarParameter>()
            {
                new SugarParameter("@MethodConst0", x2), new SugarParameter("@MethodConst1", 11), new SugarParameter("@Const3", x2)
            }, "DateAddByType error");
        }