Browse Source

-

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
7172e67d5f
  1. 2
      Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/DbBindAccessory.cs
  2. 6
      Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs
  3. 2
      Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs
  4. 4
      Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs
  5. 6
      Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs
  6. 2
      Src/Asp.Net/SqlSugar/Infrastructure/SqlSugarAccessory.cs
  7. 12
      Src/Asp.Net/SqlSugar/IntegrationServices/CacheService.cs
  8. 11
      Src/Asp.Net/SqlSugar/IntegrationServices/SerializeService.cs
  9. 2
      Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs
  10. 4
      Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs
  11. 4
      Src/Asp.Net/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs

2
Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/DbBindAccessory.cs

@ -11,7 +11,7 @@ namespace SqlSugar
{
Type type = typeof(T);
string key = "DataReaderToList." + fields + context.CurrentConnectionConfig.DbType + type.FullName;
IDataReaderEntityBuilder<T> entytyList = context.Utilities.GetCacheInstance().GetOrCreate(key, () =>
IDataReaderEntityBuilder<T> entytyList = context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(key, () =>
{
var cacheResult = new IDataReaderEntityBuilder<T>(context, dataReader).CreateBuilder(type);
return cacheResult;

6
Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs

@ -41,7 +41,7 @@ namespace SqlSugar
{
string cacheKey = "DbMaintenanceProvider.GetIsIdentities" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey);
return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,() =>
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,() =>
{
var result = GetColumnInfosByTableName(tableName).Where(it => it.IsIdentity).ToList();
return result.Select(it => it.DbColumnName).ToList();
@ -51,7 +51,7 @@ namespace SqlSugar
{
string cacheKey = "DbMaintenanceProvider.GetPrimaries" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey);
return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,() =>
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,() =>
{
var result = GetColumnInfosByTableName(tableName).Where(it => it.IsPrimarykey).ToList();
return result.Select(it => it.DbColumnName).ToList();
@ -206,7 +206,7 @@ namespace SqlSugar
#region Private
private List<T> GetListOrCache<T>(string cacheKey, string sql)
{
return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
() =>
{
var isEnableLogEvent = this.Context.Ado.IsEnableLogEvent;

2
Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs

@ -18,7 +18,7 @@ namespace SqlSugar
public EntityInfo GetEntityInfo(Type type)
{
string cacheKey = "GetEntityInfo" + type.FullName;
return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
() =>
{
EntityInfo result = new EntityInfo();

4
Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs

@ -263,9 +263,9 @@ namespace SqlSugar
#endregion
#region Cache
public ICacheService GetCacheInstance()
public ICacheService GetReflectionInoCacheInstance()
{
return ReflectionInoCache.GetInstance();
return InstanceFactory.GetReflectionInoCacheInstance();
}
public void RemoveCacheAll()

6
Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs

@ -356,13 +356,13 @@ namespace SqlSugar
#endregion
#region Services
public static ICacheService GetCacheInstance()
public static ICacheService GetReflectionInoCacheInstance()
{
return ReflectionInoCache.GetInstance();
return DefaultServices.ReflectionInoCache;
}
public static ISerializeService GetSerializeInstance()
{
return SerializeService.GetInstance();
return DefaultServices.Serialize;
}
#endregion
}

2
Src/Asp.Net/SqlSugar/Infrastructure/SqlSugarAccessory.cs

@ -98,7 +98,7 @@ namespace SqlSugar
public void InitMppingInfo(Type type)
{
string cacheKey = "Context.InitAttributeMappingTables" + type.FullName;
var entityInfo = this.Context.Utilities.GetCacheInstance().GetOrCreate<EntityInfo>(cacheKey,
var entityInfo = this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate<EntityInfo>(cacheKey,
() =>
{
var reval = this.Context.EntityMaintenance.GetEntityInfo(type);

12
Src/Asp.Net/SqlSugar/IntegrationServices/CacheService.cs

@ -8,18 +8,6 @@ namespace SqlSugar
{
public class ReflectionInoCache : ICacheService
{
private static ReflectionInoCache _instance = null;
private static readonly object _instanceLock = new object();
public static ReflectionInoCache GetInstance()
{
if (_instance == null)
lock (_instanceLock)
if (_instance == null)
{
_instance = new ReflectionInoCache();
}
return _instance;
}
public void Add<V>(string key, V value)
{
ReflectionInoCache<V>.GetInstance().Add(key,value);

11
Src/Asp.Net/SqlSugar/IntegrationServices/SerializeService.cs

@ -8,17 +8,6 @@ namespace SqlSugar
{
public class SerializeService:ISerializeService
{
private static SerializeService _instance = null;
private static readonly object _instanceLock = new object();
public static SerializeService GetInstance() {
if (_instance == null)
lock (_instanceLock)
if (_instance == null)
{
_instance = new SerializeService();
}
return _instance;
}
public string SerializeObject(object value)
{
return JsonConvert.SerializeObject(value);

2
Src/Asp.Net/SqlSugar/Interface/IContextMethods.cs

@ -18,7 +18,7 @@ namespace SqlSugar
T TranslateCopy<T>(T sourceObject);
SqlSugarClient CopyContext(SqlSugarClient context, bool isCopyEvents = false);
dynamic DataTableToDynamic(DataTable table);
ICacheService GetCacheInstance();
ICacheService GetReflectionInoCacheInstance();
void RemoveCacheAll();
void RemoveCacheAll<T>();
void RemoveCache<T>(string key);

4
Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs

@ -170,7 +170,7 @@ namespace SqlSugar
{
string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey);
return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
() =>
{
string sql = "select * from " + tableName + " WHERE 1=2 ";
@ -207,7 +207,7 @@ namespace SqlSugar
{
string cacheKey = "DbMaintenanceProvider.GetPrimaryKeyByTableNames." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey);
return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
() =>
{
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;

4
Src/Asp.Net/SqlSugar/Realization/Sqlite/DbMaintenance/SqliteDbMaintenance.cs

@ -168,7 +168,7 @@ namespace SqlSugar
{
string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey);
return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
() =>
{
string sql = "select * from " + tableName + " limit 0,1";
@ -256,7 +256,7 @@ namespace SqlSugar
}
private List<T> GetListOrCache<T>(string cacheKey, string sql)
{
return this.Context.Utilities.GetCacheInstance().GetOrCreate(cacheKey,
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
() =>
{
var isEnableLogEvent = this.Context.Ado.IsEnableLogEvent;

Loading…
Cancel
Save