Update exp to sql

This commit is contained in:
sunkaixuan
2025-10-15 16:52:27 +08:00
parent 6fdfb7bf8f
commit 262fe19f76
2 changed files with 18 additions and 1 deletions

View File

@@ -304,10 +304,22 @@ namespace SqlSugar
{
this.context.CurrentShortName=ExpressionTool.GetParameters(allMethods.FirstOrDefault()).FirstOrDefault().Name;
}
var hasNolock = false;
List<string> result = isubList.Select(it =>
{
it.HasWhere = isHasWhere;
return it.GetValue(it.Expression);
if (it is SubWithNolock)
{
hasNolock = true;
}
var result = it.GetValue(it.Expression);
var isJoin = (it is SubLeftJoin || it is SubInnerJoin);
var isSqlServer =UtilMethods.GetDatabaseType(this.context) == DbType.SqlServer;
if (hasNolock && isJoin&& isSqlServer)
{
result = result.Replace("] ON (", "] " + SqlWith.NoLock + " ON (");
}
return result;
}).ToList();
if (this.context?.SugarContext?.Context?.CurrentConnectionConfig?.DbType == DbType.Oracle && isubList.Any(s => s is SubSelect) && isubList.Any(s => s is SubOrderBy || s is SubOrderByDesc))
{
@@ -319,6 +331,7 @@ namespace SqlSugar
return result;
}
private static void SetOrderByIndex(List<ISubOperation> isubList)
{
var orderByIndex = 0;

View File

@@ -19,6 +19,10 @@ namespace SqlSugar
public class UtilMethods
{
internal static DbType? GetDatabaseType(ExpressionContext context)
{
return context?.SugarContext?.Context?.CurrentConnectionConfig?.DbType;
}
internal static void SetDefaultValueForBoolean(EntityColumnInfo item, Type propertyType)
{
if (propertyType == UtilConstants.BoolType && item.DefaultValue != null && item.DefaultValue.EqualCase("true"))