Synchronization code

This commit is contained in:
sunkaixuan 2024-04-08 10:16:32 +08:00
parent 6d378321f4
commit dfa910d2da
3 changed files with 30 additions and 1 deletions

View File

@ -199,10 +199,19 @@ namespace SqlSugar
{
throw new NotSupportedException("Can only be used in expressions");
}
public static bool GreaterThan_LinqDynamicCore(object thisValue, object ltValue)
{
throw new NotSupportedException("Can only be used in expressions");
}
public static bool LessThan(object thisValue, object ltValue)
{
throw new NotSupportedException("Can only be used in expressions");
}
public static bool LessThan_LinqDynamicCore(object thisValue, object ltValue)
{
throw new NotSupportedException("Can only be used in expressions");
}
public static bool LessThanOrEqual(object thisValue, object ltValue)
{
throw new NotSupportedException("Can only be used in expressions");

View File

@ -970,6 +970,10 @@ namespace SqlSugar
return this.Context.DbMehtods.Like(model);
case "ToSingle":
return this.Context.DbMehtods.ToSingle(model);
case "GreaterThan_LinqDynamicCore":
return this.Context.DbMehtods.GreaterThan(model);
case "LessThan_LinqDynamicCore":
return this.Context.DbMehtods.LessThan(model);
default:
if (typeof(IDbMethods).GetMethods().Any(it => it.Name == name))
{

View File

@ -23,6 +23,8 @@ namespace SqlSugar
var sql = ReplaceFormatParameters(whereSql.Format);
sql = CompatibleDynamicLinqCoreBug(sql);
// 构建动态表达式,使用常量表达式和 whereSql 中的参数值
var lambda = SqlSugarDynamicExpressionParser.ParseLambda(
new[] { parameter },
@ -33,6 +35,20 @@ namespace SqlSugar
return lambda;
}
private static string CompatibleDynamicLinqCoreBug(string sql)
{
//Compatible DynamicCore.Linq bug
if (sql?.Contains("SqlFunc.") == true)
{
sql = sql.Replace("SqlFunc.LessThan(", "SqlFunc.LessThan_LinqDynamicCore(");
sql = sql.Replace("SqlFunc.LessThan (", "SqlFunc.LessThan_LinqDynamicCore (");
sql = sql.Replace("SqlFunc.GreaterThan(", "SqlFunc.GreaterThan_LinqDynamicCore(");
sql = sql.Replace("SqlFunc.GreaterThan (", "SqlFunc.GreaterThan_LinqDynamicCore (");
}
return sql;
}
public static LambdaExpression GetObject(Type entityType, string shortName, FormattableString whereSql)
{
var parameter = Expression.Parameter(entityType, shortName);