diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs index 998e2edc0..57b07109c 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs @@ -755,7 +755,16 @@ namespace SqlSugar return $" ({likeString1} or {likeString2} or {likeString3} or {fullString}={value} ) "; } - + public string Like(MethodCallExpressionModel model) + { + var parameter = model.Args[0]; + var parameter2 = model.Args[1]; + return string.Format(" ({0} like {1} ) ", parameter.MemberName, parameter2.MemberName); + } + public string ToSingle(MethodCallExpressionModel model) + { + return ToDecimal(model); + } public string ListAny(MethodCallExpressionModel model) { if (IsArrayAnyParameter(model)) diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs index 35adff053..b0b124dae 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs @@ -111,5 +111,7 @@ namespace SqlSugar string ListAny(MethodCallExpressionModel model); string GetTableWithDataBase(string databaseName,string tableName); string Modulo(MethodCallExpressionModel mode); + string Like(MethodCallExpressionModel mode); + string ToSingle(MethodCallExpressionModel mode); } } diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs index 1ce466d86..e67336ede 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs @@ -9,6 +9,10 @@ namespace SqlSugar { public partial class SqlFunc { + public static bool Like(string fieldName, string likeValue) + { + throw new NotSupportedException("Can only be used in expressions"); + } public static int Modulo(decimal numA, decimal numB) { throw new NotSupportedException("Can only be used in expressions"); @@ -228,6 +232,7 @@ namespace SqlSugar public static string MergeString(string value1, string value2, string value3, string value4, string value5,string value6) { throw new NotSupportedException("Can only be used in expressions"); } public static string MergeString(string value1, string value2, string value3, string value4, string value5, string value6,string value7) { throw new NotSupportedException("Can only be used in expressions"); } public static int ToInt32(object value) { return value.ObjToInt(); } + public static float ToSingle(object value) { return Convert.ToSingle(value); } public static long ToInt64(object value) { return Convert.ToInt64(value); } /// /// yyyy-MM-dd HH:mm:ss.fff diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs index 19762f16b..2d4ef7f14 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs @@ -846,6 +846,10 @@ namespace SqlSugar return this.Context.DbMehtods.ListAny(model); case "Modulo": return this.Context.DbMehtods.Modulo(model); + case "Like": + return this.Context.DbMehtods.Like(model); + case "ToSingle": + return this.Context.DbMehtods.ToSingle(model); default: break; }