Synchronous code

This commit is contained in:
sunkaixuan
2025-10-28 10:32:26 +08:00
parent 4b4aa7b3be
commit 30f8edbeb6
5 changed files with 43 additions and 12 deletions

View File

@@ -555,11 +555,11 @@ WHERE table_name = '"+tableName+"'");
private List<string> GetPrimaryKeyByTableNames(string tableName)
{
string cacheKey = "DbMaintenanceProvider.GetPrimaryKeyByTableNames." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey);
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
() =>
{
//string cacheKey = "DbMaintenanceProvider.GetPrimaryKeyByTableNames." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
//cacheKey = GetCacheKey(cacheKey);
//return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
// () =>
// {
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
this.Context.Ado.IsEnableLogEvent = false;
string sql = @" select distinct cu.COLUMN_name KEYNAME from user_cons_columns cu, user_constraints au
@@ -568,7 +568,7 @@ WHERE table_name = '"+tableName+"'");
var pks = this.Context.Ado.SqlQuery<string>(sql);
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
return pks;
});
//});
}
public string GetTableComment(string tableName)
@@ -686,7 +686,7 @@ WHERE table_name = '"+tableName+"'");
}
private static void ConvertCreateColumnInfo(DbColumnInfo x)
{
string[] array = new string[] { "int","date"};
string[] array = new string[] { "int","date","clob","nclob"};
if (x.OracleDataType.HasValue())
{
x.DataType = x.OracleDataType;

View File

@@ -76,6 +76,11 @@ namespace SqlSugar
}
public partial class OracleMethod : DefaultDbMethod, IDbMethods
{
public override string UNIX_TIMESTAMP(MethodCallExpressionModel model)
{
var parameterNameA = model.Args[0].MemberName;
return $" (CAST({parameterNameA} AS DATE) - DATE '1970-01-01') * 86400 ";
}
public override string IsNullOrEmpty(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
@@ -238,11 +243,10 @@ namespace SqlSugar
switch (type)
{
case DateType.Year:
time = 1 * 365;
break;
// 每年 = 12 个月
return $"ADD_MONTHS({parameter.MemberName}, ({parameter2.MemberName}) * 12)";
case DateType.Month:
time = 1 *30;
break;
return $"ADD_MONTHS({parameter.MemberName}, {parameter2.MemberName})";
case DateType.Day:
break;
case DateType.Hour:

View File

@@ -176,6 +176,16 @@ namespace SqlSugar
{
return Convert.ToInt64(value);
}
else if (value is TimeSpan ts)
{
return string.Format(
"INTERVAL '{0} {1:D2}:{2:D2}:{3:D2}.{4:D3}' DAY TO SECOND(3)",
ts.Days,
ts.Hours,
ts.Minutes,
ts.Seconds,
ts.Milliseconds);
}
else if (type == UtilConstants.ByteArrayType)
{
++i;

View File

@@ -27,6 +27,10 @@ namespace SqlSugar
{
return OffsetPage();
}
else if (this.Take==1&&this.Skip==0)
{
return OffsetPage();
}
var oldTake = Take;
var oldSkip = Skip;
var isDistinctPage = IsDistinct && (Take > 1 || Skip > 1);
@@ -135,6 +139,9 @@ namespace SqlSugar
string temp = isExternal ? ExternalPageTempalte : PageTempalte;
return string.Format(temp, sql.ToString(), (pageIndex - 1) * pageSize + 1, pageIndex * pageSize);
}
public override string GetExternalOrderBy(string externalOrderBy)
{
return Regex.Replace(externalOrderBy, @"\""\w+\""\.", "");
}
}
}

View File

@@ -106,6 +106,16 @@ namespace SqlSugar
{
return value.ObjToBool() ? "1" : "0";
}
else if (value is TimeSpan ts)
{
return string.Format(
"INTERVAL '{0} {1:D2}:{2:D2}:{3:D2}.{4:D3}' DAY TO SECOND(3)",
ts.Days,
ts.Hours,
ts.Minutes,
ts.Seconds,
ts.Milliseconds );
}
else if (type == UtilConstants.DateTimeOffsetType)
{
var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value);