private void EndsWith() { Expression <Func <Student, bool> > exp = it => SqlFunc.EndsWith(it.Name, "a"); SqliteExpressionContext expContext = new SqliteExpressionContext(); 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") }, "EndsWith"); }
private void Length() { Expression <Func <Student, bool> > exp = it => SqlFunc.Length("aaaa") > 1; SqliteExpressionContext expContext = new SqliteExpressionContext(); 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"); }
private void StringIsNullOrEmpty5() { WhereConst.name = "xx"; Expression <Func <Student, bool> > exp = it => !SqlFunc.IsNullOrEmpty(WhereConst.name);; SqliteExpressionContext expContext = new SqliteExpressionContext(); 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"); }
private void StringIsNullOrEmpty2() { Expression <Func <Student, bool> > exp = it => 2 == it.Id || SqlFunc.IsNullOrEmpty(true);; SqliteExpressionContext expContext = new SqliteExpressionContext(); 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"); }
private void DateIsSameByDay() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => SqlFunc.DateIsSame(x2, x2); SqliteExpressionContext expContext = new SqliteExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, " Cast((JulianDay(@MethodConst0) - JulianDay(@MethodConst1)) *1 As INTEGER)=0 ", new List <SugarParameter>() { new SugarParameter("@MethodConst0", x2), new SugarParameter("@MethodConst1", x2) }, "DateIsSameDay error"); }
private void DateAddDay() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => SqlFunc.DateAdd(x2, 1) == x2; SqliteExpressionContext expContext = new SqliteExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(DATE(DATETIME(@MethodConst0), '+1 days') = @Const2 )", new List <SugarParameter>() { new SugarParameter("@MethodConst0", x2), new SugarParameter("@MethodConst1", 1), new SugarParameter("@Const2", x2) }, "DateAddDay error"); }
private void DateValue() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => SqlFunc.DateValue(x2, DateType.Year) == 1; SqliteExpressionContext expContext = new SqliteExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(CAST(STRFTIME('%Y', DATETIME(DATETIME(@MethodConst0), 'LOCALTIME')) AS INTEGER) = @Const2 )", new List <SugarParameter>() { new SugarParameter("@MethodConst0", x2), new SugarParameter("@Const2", 1) }, "DateValue error"); }
private void ToInt32() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => SqlFunc.ToInt32("3") == 1; SqliteExpressionContext expContext = new SqliteExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(CAST(@MethodConst0 AS INTEGER) = @Const1 )", new List <SugarParameter>() { new SugarParameter("@MethodConst0", "3"), new SugarParameter("@Const1", 1) }, "ToInt32 error"); }
private void ExtendDate() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => Convert.ToDateTime("2015-1-1") == x2; SqliteExpressionContext expContext = new SqliteExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(DATETIME(@MethodConst0) = @Const1 )", new List <SugarParameter>() { new SugarParameter("@MethodConst0", "2015-1-1"), new SugarParameter("@Const1", x2) }, "ExtendDate error"); }
private void ToGuid() { var x2 = Guid.NewGuid(); Expression <Func <Student, bool> > exp = it => SqlFunc.ToGuid("A94027A3-476E-478D-8228-F4054394B874") == x2; SqliteExpressionContext expContext = new SqliteExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(CAST(@MethodConst0 AS TEXT) = @Const1 )", new List <SugarParameter>() { new SugarParameter("@MethodConst0", "A94027A3-476E-478D-8228-F4054394B874"), new SugarParameter("@Const1", x2) }, "ToGuid error"); }
private void ToDouble() { var x2 = Guid.NewGuid(); Expression <Func <Student, bool> > exp = it => SqlFunc.ToDouble("2") == 2; SqliteExpressionContext expContext = new SqliteExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(CAST(@MethodConst0 AS DECIMAL(18,4)) = @Const1 )", new List <SugarParameter>() { new SugarParameter("@MethodConst0", "2"), new SugarParameter("@Const1", (Double)2) }, "ToDouble error"); }
private void ToBool() { var x2 = Guid.NewGuid(); Expression <Func <Student, bool> > exp = it => SqlFunc.ToBool("true") == true; SqliteExpressionContext expContext = new SqliteExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(CAST(@MethodConst0 AS SIGNED) = @Const1 )", new List <SugarParameter>() { new SugarParameter("@MethodConst0", "true"), new SugarParameter("@Const1", (bool)true) }, "ToBool error"); }
private void ExtendSubstring() { var x2 = Guid.NewGuid(); Expression <Func <Student, bool> > exp = it => "aaaa".Substring(0, 2) == "a"; SqliteExpressionContext expContext = new SqliteExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(SUBSTR(@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"); }
private void Replace() { var x2 = Guid.NewGuid(); Expression <Func <Student, bool> > exp = it => SqlFunc.Replace("aaaa", "a", "1") == "a"; SqliteExpressionContext expContext = new SqliteExpressionContext(); 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"); }
private void IIF2() { Expression <Func <Student, bool> > exp = it => SqlFunc.IIF(SqlFunc.Contains(it.Name, "a"), 1, 2) == 1; SqliteExpressionContext expContext = new SqliteExpressionContext(); 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"); }