diff --git a/Src/Asp.Net/SqlSugar/SqlSugar.nuspec b/Src/Asp.Net/SqlSugar/SqlSugar.nuspec index c8fd5ede3..0f628985b 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugar.nuspec +++ b/Src/Asp.Net/SqlSugar/SqlSugar.nuspec @@ -2,7 +2,7 @@ sqlSugar - 4.2.1.3 + 4.2.1.5 SqlSugar SqlServer ORM sun kaixuan landa diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs index 7a70975e2..a3b83628a 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs @@ -10,8 +10,9 @@ namespace SqlSugar #region DML public virtual List GetViewInfoList() { - string key = "DbMaintenanceProvider.GetViewInfoList"; - var result = GetListOrCache(key, this.GetViewInfoListSql); + string cacheKey = "DbMaintenanceProvider.GetViewInfoList"; + cacheKey = GetCacheKey(cacheKey); + var result = GetListOrCache(cacheKey, this.GetViewInfoListSql); foreach (var item in result) { item.DbObjectType = DbObjectType.View; @@ -20,8 +21,9 @@ namespace SqlSugar } public virtual List GetTableInfoList() { - string key = "DbMaintenanceProvider.GetTableInfoList"; - var result = GetListOrCache(key, this.GetTableInfoListSql); + string cacheKey = "DbMaintenanceProvider.GetTableInfoList"; + cacheKey = GetCacheKey(cacheKey); + var result = GetListOrCache(cacheKey, this.GetTableInfoListSql); foreach (var item in result) { item.DbObjectType = DbObjectType.Table; @@ -31,12 +33,14 @@ namespace SqlSugar public virtual List GetColumnInfosByTableName(string tableName) { if (string.IsNullOrEmpty(tableName)) return new List(); - string key = "DbMaintenanceProvider.GetColumnInfosByTableName." +this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); - return GetListOrCache(key, string.Format(this.GetColumnInfosByTableNameSql, tableName)); + string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); + cacheKey = GetCacheKey(cacheKey); + return GetListOrCache(cacheKey, string.Format(this.GetColumnInfosByTableNameSql, tableName)); } public virtual List GetIsIdentities(string tableName) { - string cacheKey = "DbMaintenanceProvider.GetIsIdentities" +this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); + string cacheKey = "DbMaintenanceProvider.GetIsIdentities" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); + cacheKey = GetCacheKey(cacheKey); return this.Context.RewritableMethods.GetCacheInstance>().Func(cacheKey, (cm, key) => { @@ -50,7 +54,8 @@ namespace SqlSugar } public virtual List GetPrimaries(string tableName) { - string cacheKey = "DbMaintenanceProvider.GetPrimaries" +this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); + string cacheKey = "DbMaintenanceProvider.GetPrimaries" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); + cacheKey = GetCacheKey(cacheKey); return this.Context.RewritableMethods.GetCacheInstance>().Func(cacheKey, (cm, key) => { @@ -107,11 +112,11 @@ namespace SqlSugar public virtual bool IsAnySystemTablePermissions() { string sql = this.CheckSystemTablePermissionsSql; + this.Context.Ado.CheckConnection(); try { var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; this.Context.Ado.IsEnableLogEvent = false; - this.Context.Ado.CheckConnection(); this.Context.Ado.ExecuteCommand(sql); this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; return true; @@ -127,8 +132,8 @@ namespace SqlSugar public virtual bool AddPrimaryKey(string tableName, string columnName) { tableName = this.SqlBuilder.GetTranslationTableName(tableName); - columnName=this.SqlBuilder.GetTranslationTableName(columnName); - string sql = string.Format(this.AddPrimaryKeySql,tableName, string.Format("PK_{0}_{1}",this.SqlBuilder.GetNoTranslationColumnName(tableName), this.SqlBuilder.GetNoTranslationColumnName(columnName)), columnName); + columnName = this.SqlBuilder.GetTranslationTableName(columnName); + string sql = string.Format(this.AddPrimaryKeySql, tableName, string.Format("PK_{0}_{1}", this.SqlBuilder.GetNoTranslationColumnName(tableName), this.SqlBuilder.GetNoTranslationColumnName(columnName)), columnName); this.Context.Ado.ExecuteCommand(sql); return true; } @@ -156,7 +161,7 @@ namespace SqlSugar public virtual bool DropTable(string tableName) { tableName = this.SqlBuilder.GetTranslationTableName(tableName); - this.Context.Ado.ExecuteCommand(string.Format(this.DropTableSql,tableName)); + this.Context.Ado.ExecuteCommand(string.Format(this.DropTableSql, tableName)); return true; } public virtual bool DropColumn(string tableName, string columnName) @@ -193,7 +198,7 @@ namespace SqlSugar { oldTableName = this.SqlBuilder.GetTranslationTableName(oldTableName); newTableName = this.SqlBuilder.GetTranslationTableName(newTableName); - string sql = string.Format(this.BackupTableSql,newTableName , oldTableName, maxBackupDataRows); + string sql = string.Format(this.BackupTableSql, newTableName, oldTableName, maxBackupDataRows); this.Context.Ado.ExecuteCommand(sql); return true; } @@ -231,21 +236,21 @@ namespace SqlSugar Check.Exception(columns.IsNullOrEmpty(), "No columns found "); foreach (var item in columns) { - string columnName =this.SqlBuilder.GetTranslationTableName(item.DbColumnName); + string columnName = this.SqlBuilder.GetTranslationTableName(item.DbColumnName); string dataType = item.DataType; string dataSize = item.Length > 0 ? string.Format("({0})", item.Length) : null; string nullType = item.IsNullable ? this.CreateTableNull : CreateTableNotNull; string primaryKey = null; string identity = item.IsIdentity ? this.CreateTableIdentity : null; - string addItem = string.Format(this.CreateTableColumn,columnName, dataType, dataSize, nullType, primaryKey, identity); + string addItem = string.Format(this.CreateTableColumn, columnName, dataType, dataSize, nullType, primaryKey, identity); columnArray.Add(addItem); } - string tableString = string.Format(this.CreateTableSql,this.SqlBuilder.GetTranslationTableName(tableName), string.Join(",\r\n", columnArray)); + string tableString = string.Format(this.CreateTableSql, this.SqlBuilder.GetTranslationTableName(tableName), string.Join(",\r\n", columnArray)); return tableString; } protected virtual string GetAddColumnSql(string tableName, DbColumnInfo columnInfo) { - string columnName=this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName); + string columnName = this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName); tableName = this.SqlBuilder.GetTranslationTableName(tableName); string dataType = columnInfo.DataType; string dataSize = columnInfo.Length > 0 ? string.Format("({0})", columnInfo.Length) : null; @@ -257,7 +262,7 @@ namespace SqlSugar } protected virtual string GetUpdateColumnSql(string tableName, DbColumnInfo columnInfo) { - string columnName =this.SqlBuilder.GetTranslationTableName(columnInfo.DbColumnName); + string columnName = this.SqlBuilder.GetTranslationTableName(columnInfo.DbColumnName); tableName = this.SqlBuilder.GetTranslationTableName(tableName); string dataType = columnInfo.DataType; string dataSize = columnInfo.Length > 0 ? string.Format("({0})", columnInfo.Length) : null; @@ -267,6 +272,10 @@ namespace SqlSugar string result = string.Format(this.AlterColumnToTableSql, tableName, columnName, dataType, dataSize, nullType, primaryKey, identity); return result; } + protected virtual string GetCacheKey(string cacheKey) + { + return this.Context.CurrentConnectionConfig.DbType + "." + this.Context.Ado.Connection.Database +"."+ cacheKey; + } #endregion } } diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs index 237883ca1..31d54824d 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Properties/AssemblyInfo.cs @@ -17,5 +17,5 @@ using System.Runtime.InteropServices; // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("1c022a5c-4e4d-4026-a8a3-f659b9740a1a")] -[assembly: AssemblyVersion("4.2.1.1")] -[assembly: AssemblyFileVersion("4.2.1.1")] +[assembly: AssemblyVersion("4.2.1.5")] +[assembly: AssemblyFileVersion("4.2.1.5")] diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs index 0076608ef..e838839f1 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs @@ -168,6 +168,7 @@ namespace SqlSugar public override List GetColumnInfosByTableName(string tableName) { string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); + cacheKey = GetCacheKey(cacheKey); return this.Context.RewritableMethods.GetCacheInstance>().Func(cacheKey, (cm, key) => { diff --git a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec index b47853b94..027de2133 100644 --- a/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec +++ b/Src/Asp.NetCore/SqlServerTest/src/SqlSugar/SqlSugarForCore.nuspec @@ -2,7 +2,7 @@ sqlSugarCore - 4.2.1.1 + 4.2.1.5 sunkaixuan Landa http://www.apache.org/licenses/LICENSE-2.0.html