Update Core

This commit is contained in:
sunkaixuan 2017-07-19 01:00:44 +08:00
parent d1f2310dc3
commit 5c516c91e8
5 changed files with 32 additions and 22 deletions

View File

@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>sqlSugar</id> <id>sqlSugar</id>
<version>4.2.1.3</version> <version>4.2.1.5</version>
<title>SqlSugar SqlServer ORM</title> <title>SqlSugar SqlServer ORM</title>
<authors>sun kaixuan</authors> <authors>sun kaixuan</authors>
<owners>landa</owners> <owners>landa</owners>

View File

@ -10,8 +10,9 @@ namespace SqlSugar
#region DML #region DML
public virtual List<DbTableInfo> GetViewInfoList() public virtual List<DbTableInfo> GetViewInfoList()
{ {
string key = "DbMaintenanceProvider.GetViewInfoList"; string cacheKey = "DbMaintenanceProvider.GetViewInfoList";
var result = GetListOrCache<DbTableInfo>(key, this.GetViewInfoListSql); cacheKey = GetCacheKey(cacheKey);
var result = GetListOrCache<DbTableInfo>(cacheKey, this.GetViewInfoListSql);
foreach (var item in result) foreach (var item in result)
{ {
item.DbObjectType = DbObjectType.View; item.DbObjectType = DbObjectType.View;
@ -20,8 +21,9 @@ namespace SqlSugar
} }
public virtual List<DbTableInfo> GetTableInfoList() public virtual List<DbTableInfo> GetTableInfoList()
{ {
string key = "DbMaintenanceProvider.GetTableInfoList"; string cacheKey = "DbMaintenanceProvider.GetTableInfoList";
var result = GetListOrCache<DbTableInfo>(key, this.GetTableInfoListSql); cacheKey = GetCacheKey(cacheKey);
var result = GetListOrCache<DbTableInfo>(cacheKey, this.GetTableInfoListSql);
foreach (var item in result) foreach (var item in result)
{ {
item.DbObjectType = DbObjectType.Table; item.DbObjectType = DbObjectType.Table;
@ -31,12 +33,14 @@ namespace SqlSugar
public virtual List<DbColumnInfo> GetColumnInfosByTableName(string tableName) public virtual List<DbColumnInfo> GetColumnInfosByTableName(string tableName)
{ {
if (string.IsNullOrEmpty(tableName)) return new List<DbColumnInfo>(); if (string.IsNullOrEmpty(tableName)) return new List<DbColumnInfo>();
string key = "DbMaintenanceProvider.GetColumnInfosByTableName." +this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
return GetListOrCache<DbColumnInfo>(key, string.Format(this.GetColumnInfosByTableNameSql, tableName)); cacheKey = GetCacheKey(cacheKey);
return GetListOrCache<DbColumnInfo>(cacheKey, string.Format(this.GetColumnInfosByTableNameSql, tableName));
} }
public virtual List<string> GetIsIdentities(string tableName) public virtual List<string> 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<List<string>>().Func(cacheKey, return this.Context.RewritableMethods.GetCacheInstance<List<string>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
@ -51,6 +55,7 @@ namespace SqlSugar
public virtual List<string> GetPrimaries(string tableName) public virtual List<string> 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<List<string>>().Func(cacheKey, return this.Context.RewritableMethods.GetCacheInstance<List<string>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
@ -107,11 +112,11 @@ namespace SqlSugar
public virtual bool IsAnySystemTablePermissions() public virtual bool IsAnySystemTablePermissions()
{ {
string sql = this.CheckSystemTablePermissionsSql; string sql = this.CheckSystemTablePermissionsSql;
this.Context.Ado.CheckConnection();
try try
{ {
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent; var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
this.Context.Ado.IsEnableLogEvent = false; this.Context.Ado.IsEnableLogEvent = false;
this.Context.Ado.CheckConnection();
this.Context.Ado.ExecuteCommand(sql); this.Context.Ado.ExecuteCommand(sql);
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog; this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
return true; return true;
@ -267,6 +272,10 @@ namespace SqlSugar
string result = string.Format(this.AlterColumnToTableSql, tableName, columnName, dataType, dataSize, nullType, primaryKey, identity); string result = string.Format(this.AlterColumnToTableSql, tableName, columnName, dataType, dataSize, nullType, primaryKey, identity);
return result; return result;
} }
protected virtual string GetCacheKey(string cacheKey)
{
return this.Context.CurrentConnectionConfig.DbType + "." + this.Context.Ado.Connection.Database +"."+ cacheKey;
}
#endregion #endregion
} }
} }

View File

@ -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 // 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: Guid("1c022a5c-4e4d-4026-a8a3-f659b9740a1a")]
[assembly: AssemblyVersion("4.2.1.1")] [assembly: AssemblyVersion("4.2.1.5")]
[assembly: AssemblyFileVersion("4.2.1.1")] [assembly: AssemblyFileVersion("4.2.1.5")]

View File

@ -168,6 +168,7 @@ namespace SqlSugar
public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName) public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName)
{ {
string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey);
return this.Context.RewritableMethods.GetCacheInstance<List<DbColumnInfo>>().Func(cacheKey, return this.Context.RewritableMethods.GetCacheInstance<List<DbColumnInfo>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {

View File

@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>sqlSugarCore</id> <id>sqlSugarCore</id>
<version>4.2.1.1</version> <version>4.2.1.5</version>
<authors>sunkaixuan</authors> <authors>sunkaixuan</authors>
<owners>Landa</owners> <owners>Landa</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl> <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>