Support ILike

This commit is contained in:
sunkaixuan
2024-06-07 21:41:39 +08:00
parent fb4cff1a24
commit ae2c42cae4

View File

@@ -649,6 +649,7 @@ namespace SqlSugar
}
else
{
var iLike = this.Context?.SugarContext?.Context?.CurrentConnectionConfig?.MoreSettings?.EnableILike == true;
if (name == "Parse" && TempParseType.IsIn(UtilConstants.GuidType) && model.Args != null && model.Args.Count() > 1)
{
name = "Equals";
@@ -763,9 +764,9 @@ namespace SqlSugar
case "Between":
return this.Context.DbMehtods.Between(model);
case "StartsWith":
return this.Context.DbMehtods.StartsWith(model);
return GetLike(this.Context.DbMehtods.StartsWith(model),iLike);
case "EndsWith":
return this.Context.DbMehtods.EndsWith(model);
return GetLike(this.Context.DbMehtods.EndsWith(model), iLike);
case "ToInt32":
return this.Context.DbMehtods.ToInt32(model);
case "ToInt64":
@@ -974,7 +975,7 @@ namespace SqlSugar
case "Modulo":
return this.Context.DbMehtods.Modulo(model);
case "Like":
return this.Context.DbMehtods.Like(model);
return GetLike(this.Context.DbMehtods.Like(model),iLike);
case "ToSingle":
return this.Context.DbMehtods.ToSingle(model);
case "GreaterThan_LinqDynamicCore":
@@ -991,6 +992,16 @@ namespace SqlSugar
}
return null;
}
private string GetLike(string result, bool iLike)
{
if (iLike)
{
result = result.Replace(" like ", " ilike ");
}
return result;
}
private DbType GetType(string name)
{
DbType result = DbType.SqlServer;