修复 sqldb oracle11 标识符过长

This commit is contained in:
Kimdiego2098
2024-03-07 12:11:20 +08:00
parent c1a027a771
commit 8abfeb5923
3 changed files with 14 additions and 5 deletions

View File

@@ -15,9 +15,9 @@ using ThingsGateway.Core;
namespace ThingsGateway.Plugin.SqlDB;
[SugarTable(TableDescription = "设备采集实时表")]
[SugarIndex("index_Name", nameof(SQLHistoryValue.Name), OrderByType.Desc)]
[SugarIndex("index_DeviceName", nameof(SQLHistoryValue.DeviceName), OrderByType.Desc)]
[SugarIndex("index_CollectTime", nameof(SQLHistoryValue.CollectTime), OrderByType.Desc)]
[SugarIndex("{table}_index_Name", nameof(SQLRealValue.Name), OrderByType.Desc)]
[SugarIndex("{table}_index_DeviceName", nameof(SQLRealValue.DeviceName), OrderByType.Desc)]
[SugarIndex("{table}_index_CollectTime", nameof(SQLRealValue.CollectTime), OrderByType.Desc)]
public class SQLRealValue : IPrimaryIdEntity
{
[SugarColumn(ColumnDescription = "Id", IsPrimaryKey = true)]

View File

@@ -49,6 +49,13 @@ public static class SqlDBBusinessDatabaseUtil
ConfigureExternalServices = configureExternalServices,
}
);
if (sqlSugarClient.CurrentConnectionConfig.DbType == DbType.Oracle)
{
sqlSugarClient.CurrentConnectionConfig.MoreSettings = new()
{
MaxParameterNameLength = 30
};
}
DbContext.AopSetting(sqlSugarClient);//aop配置
return sqlSugarClient;
}

View File

@@ -61,8 +61,10 @@ YitIdHelper.NextId())
{
var db = SqlDBBusinessDatabaseUtil.GetDb(_driverPropertys);
db.CodeFirst.InitTables(typeof(SQLHistoryValue));
db.MappingTables.Add(nameof(SQLRealValue), _driverPropertys.ReadDBTableName);
db.CodeFirst.InitTables(typeof(SQLRealValue));
//新功能 5.0.2.3
db.CodeFirst.As<SQLRealValue>(_driverPropertys.ReadDBTableName).InitTables<SQLRealValue>();
//该功能索引名要加占位符
//[SugarIndex("{table}index_codetable1_name",nameof(CodeFirstTable1.Name),OrderByType.Asc)]
await base.ProtectedBeforStartAsync(cancellationToken);
}