diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs b/Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs index 25bf15df7..96af4a5d0 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs @@ -363,9 +363,9 @@ namespace OrmTest.UnitTest expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; - base.Check(value, pars, "((DATEADD(@MethodConst2,@MethodConst1,@MethodConst0)) = @Const3 )", new List() { - new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",11),new SugarParameter("@Const3",x2), - new SugarParameter("@MethodConst2",DateType.Millisecond) + base.Check(value, pars, "((DATEADD(Millisecond,@MethodConst1,@MethodConst0)) = @Const3 )", new List() { + new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",11),new SugarParameter("@Const3",x2) + }, "DateAddByType error"); } private void DateAddDay() @@ -392,8 +392,8 @@ namespace OrmTest.UnitTest expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; - base.Check(value, pars, "((DATEADD(@Const0,@MethodConst1,[Datetime2])) = @Const2 )", new List() { - new SugarParameter("@Const0",DateType.Hour.ToString()),new SugarParameter("@MethodConst1",10) + base.Check(value, pars, "((DATEADD(Hour,@MethodConst1,[Datetime2])) = @Const2 )", new List() { + new SugarParameter("@MethodConst1",10) ,new SugarParameter("@Const2",x2) }, "DateAddDay2 error"); } @@ -406,8 +406,9 @@ namespace OrmTest.UnitTest expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; - base.Check(value, pars, "((DATEADD(@Const0,@MethodConst2,@MethodConst1)) = @Const3 )", new List() { - new SugarParameter("@Const0",DateType.Hour.ToString()),new SugarParameter("@MethodConst2",1),new SugarParameter("@MethodConst1",x2) + base.Check(value, pars, "((DATEADD(Hour,@MethodConst2,@MethodConst1)) = @Const3 )", new List() { + new SugarParameter("@MethodConst2",1), + new SugarParameter("@MethodConst1",x2) ,new SugarParameter("@Const3",x2) }, "DateAddDay3 error"); } @@ -420,9 +421,8 @@ namespace OrmTest.UnitTest expContext.Resolve(exp, ResolveExpressType.WhereSingle); var value = expContext.Result.GetString(); var pars = expContext.Parameters; - base.Check(value, pars, " (DATEDIFF(@MethodConst2,@MethodConst0,@MethodConst1)=0) ", new List() { - new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",x2), - new SugarParameter("@MethodConst2",DateType.Millisecond) + base.Check(value, pars, " (DATEDIFF(Millisecond,@MethodConst0,@MethodConst1)=0) ", new List() { + new SugarParameter("@MethodConst0",x2),new SugarParameter("@MethodConst1",x2) }, "DateIsSameByType error"); } private void DateIsSameByDay() diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Method/DefaultDbMethod.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Method/DefaultDbMethod.cs index 2fdf4786e..db3578889 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Method/DefaultDbMethod.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Method/DefaultDbMethod.cs @@ -109,7 +109,7 @@ namespace SqlSugar var parameter = model.Args[0]; var parameter2 = model.Args[1]; var parameter3 = model.Args[2]; - return string.Format(" (DATEDIFF({2},{0},{1})=0) ", parameter.MemberName, parameter2.MemberName, parameter3.MemberName); + return string.Format(" (DATEDIFF({2},{0},{1})=0) ", parameter.MemberName, parameter2.MemberName, parameter3.MemberValue); } public virtual string DateAddByType(MethodCallExpressionModel model) @@ -117,7 +117,7 @@ namespace SqlSugar var parameter = model.Args[0]; var parameter2 = model.Args[1]; var parameter3 = model.Args[2]; - return string.Format(" (DATEADD({2},{1},{0})) ", parameter.MemberName, parameter2.MemberName, parameter3.MemberName); + return string.Format(" (DATEADD({2},{1},{0})) ", parameter.MemberName, parameter2.MemberName, parameter3.MemberValue); } public virtual string DateAddDay(MethodCallExpressionModel model) diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs index e79d3e92c..f9a82f750 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs @@ -215,21 +215,29 @@ namespace SqlSugar case "Contains": return this.Context.DbMehtods.Contains(model); case "ContainsArray": - var result = this.Context.DbMehtods.ContainsArray(model); + var caResult = this.Context.DbMehtods.ContainsArray(model); this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString()); - return result; + return caResult; case "Equals": return this.Context.DbMehtods.Equals(model); case "DateIsSame": if (model.Args.Count == 2) return this.Context.DbMehtods.DateIsSameDay(model); else - return this.Context.DbMehtods.DateIsSameByType(model); + { + var dsResult=this.Context.DbMehtods.DateIsSameByType(model); + this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[2].MemberName.ObjToString()); + return dsResult; + } case "DateAdd": if (model.Args.Count == 2) return this.Context.DbMehtods.DateAddDay(model); else - return this.Context.DbMehtods.DateAddByType(model); + { + var daResult=this.Context.DbMehtods.DateAddByType(model); + this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[2].MemberName.ObjToString()); + return daResult; + } case "DateValue": return this.Context.DbMehtods.DateValue(model); case "Between": diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlExpressionContext.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlExpressionContext.cs index 2736d588d..4dd6c55cc 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlExpressionContext.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlExpressionContext.cs @@ -88,7 +88,7 @@ namespace SqlSugar var parameter = model.Args[0]; var parameter2 = model.Args[1]; var parameter3 = model.Args[2]; - return string.Format(" (TIMESTAMPDIFF({2},{0},{1})=0) ", parameter.MemberName, parameter2.MemberName, parameter3.MemberName); + return string.Format(" (TIMESTAMPDIFF({2},{0},{1})=0) ", parameter.MemberName, parameter2.MemberName, parameter3.MemberValue); } public override string DateAddByType(MethodCallExpressionModel model) @@ -96,7 +96,7 @@ namespace SqlSugar var parameter = model.Args[0]; var parameter2 = model.Args[1]; var parameter3 = model.Args[2]; - return string.Format(" (DATE_ADD({1} INTERVAL {2} {0})) ", parameter.MemberName, parameter2.MemberName, parameter3.MemberName); + return string.Format(" (DATE_ADD({1} INTERVAL {2} {0})) ", parameter.MemberName, parameter2.MemberName, parameter3.MemberValue); } public override string DateAddDay(MethodCallExpressionModel model)