private void DateValue() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => SqlFunc.DateValue(x2, DateType.Year) == 1; MySqlExpressionContext expContext = new MySqlExpressionContext(); 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"); }
private void DateAddDay() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => SqlFunc.DateAdd(x2, 1) == x2; MySqlExpressionContext expContext = new MySqlExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "((DATE_ADD(@MethodConst1 INTERVAL @MethodConst0 day)) = @Const2 )", new List <SugarParameter>() { new SugarParameter("@MethodConst0", x2), new SugarParameter("@MethodConst1", 1), new SugarParameter("@Const2", x2) }, "DateIsSameByType error"); }
private void ExtendDate() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => Convert.ToDateTime("2015-1-1") == x2; MySqlExpressionContext expContext = new MySqlExpressionContext(); 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"); }
private void ToInt32() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => SqlFunc.ToInt32("3") == 1; MySqlExpressionContext expContext = new MySqlExpressionContext(); 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", "3"), new SugarParameter("@Const1", 1) }, "ToInt32 error"); }
private void ToGuid() { var x2 = Guid.NewGuid(); Expression <Func <Student, bool> > exp = it => SqlFunc.ToGuid("A94027A3-476E-478D-8228-F4054394B874") == x2; MySqlExpressionContext expContext = new MySqlExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(CAST(@MethodConst0 AS CHAR) = @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; MySqlExpressionContext expContext = new MySqlExpressionContext(); 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; MySqlExpressionContext expContext = new MySqlExpressionContext(); 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"; MySqlExpressionContext expContext = new MySqlExpressionContext(); 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"); }
private void Replace() { var x2 = Guid.NewGuid(); Expression <Func <Student, bool> > exp = it => SqlFunc.Replace("aaaa", "a", "1") == "a"; MySqlExpressionContext expContext = new MySqlExpressionContext(); 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 StringIsNullOrEmpty4() { WhereConst.name = "xx"; Expression <Func <Student, bool> > exp = it => 2 == it.Id || SqlFunc.IsNullOrEmpty(WhereConst.name);; MySqlExpressionContext expContext = new MySqlExpressionContext(); 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"); }
private void whereSingle4() { Expression <Func <Student, bool> > exp = it => (it.Id > 1 && it.Name != "a") || it.Name == "a1"; ExpressionContext expContext = new MySqlExpressionContext(); 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"); }
private void DateIsSameByType() { var x2 = DateTime.Now; Expression <Func <Student, bool> > exp = it => SqlFunc.DateIsSame(x2, x2, DateType.Millisecond); MySqlExpressionContext expContext = new MySqlExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, " (TIMESTAMPDIFF(@MethodConst2,@MethodConst0,@MethodConst1)=0) ", new List <SugarParameter>() { new SugarParameter("@MethodConst0", x2), new SugarParameter("@MethodConst1", x2), new SugarParameter("@MethodConst2", DateType.Millisecond) }, "DateIsSameByType error"); }
private void IIF2() { Expression <Func <Student, bool> > exp = it => SqlFunc.IIF(SqlFunc.Contains(it.Name, "a"), 1, 2) == 1; MySqlExpressionContext expContext = new MySqlExpressionContext(); expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; base.Check(value, pars, "(( CASE WHEN (`Name` like concat('%',@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"); }
private void IIF() { Expression <Func <Student, bool> > exp = it => SqlFunc.IIF(it.Id == 1, 1, 2) == 1; MySqlExpressionContext expContext = new MySqlExpressionContext(); 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"); }
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; ExpressionContext expContext = new MySqlExpressionContext(); 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"); }