Browse Source

Add SqlFunc.Like SqlFunc.ToSingle

pull/40/head
sunkaixuan 1 year ago
parent
commit
95c977ff0e
  1. 11
      Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs
  2. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs
  3. 5
      Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs
  4. 4
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve_Helper.cs

11
Src/Asp.Net/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))

2
Src/Asp.Net/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);
}
}

5
Src/Asp.Net/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); }
/// <summary>
/// yyyy-MM-dd HH:mm:ss.fff

4
Src/Asp.Net/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;
}

Loading…
Cancel
Save