mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-29 01:47:06 +08:00
Add Db.Fastest.RemoveDataCache
This commit is contained in:
parent
dbd014a561
commit
7797d6cb86
@ -191,12 +191,12 @@ namespace SqlSugar
|
||||
{
|
||||
var title = isAdd ? "BulkCopy" : "BulkUpdate";
|
||||
this.context.Ado.IsEnableLogEvent = isLog;
|
||||
if (this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuted != null)
|
||||
if (this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuted != null)
|
||||
{
|
||||
this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuted($"End {title} name:{GetTableName()} ,count: {datas.Count},current time: {DateTime.Now}" , new SugarParameter[] { });
|
||||
this.context.CurrentConnectionConfig?.AopEvents?.OnLogExecuted($"End {title} name:{GetTableName()} ,count: {datas.Count},current time: {DateTime.Now}", new SugarParameter[] { });
|
||||
}
|
||||
RemoveCache();
|
||||
}
|
||||
|
||||
private void Begin<Type>(List<Type> datas,bool isAdd)
|
||||
{
|
||||
var title = isAdd ? "BulkCopy" : "BulkUpdate";
|
||||
|
@ -161,5 +161,24 @@ namespace SqlSugar
|
||||
tempDataTable.TableName = dt.TableName;
|
||||
return tempDataTable;
|
||||
}
|
||||
|
||||
|
||||
private void RemoveCache()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(CacheKey) || !string.IsNullOrEmpty(CacheKeyLike))
|
||||
{
|
||||
Check.Exception(this.context.CurrentConnectionConfig.ConfigureExternalServices?.DataInfoCacheService == null, "ConnectionConfig.ConfigureExternalServices.DataInfoCacheService is null");
|
||||
var service = this.context.CurrentConnectionConfig.ConfigureExternalServices?.DataInfoCacheService;
|
||||
if (!string.IsNullOrEmpty(CacheKey))
|
||||
{
|
||||
CacheSchemeMain.RemoveCache(service, CacheKey);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(CacheKeyLike))
|
||||
{
|
||||
CacheSchemeMain.RemoveCacheByLike(service, CacheKeyLike);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,18 @@ namespace SqlSugar
|
||||
{
|
||||
private string AsName { get; set; }
|
||||
private int Size { get; set; }
|
||||
|
||||
private string CacheKey { get; set; }
|
||||
private string CacheKeyLike { get; set; }
|
||||
public IFastest<T> RemoveDataCache()
|
||||
{
|
||||
CacheKey = typeof(T).FullName;
|
||||
return this;
|
||||
}
|
||||
public IFastest<T> RemoveDataCache(string cacheKey)
|
||||
{
|
||||
CacheKeyLike = this.context.EntityMaintenance.GetTableName<T>();
|
||||
return this;
|
||||
}
|
||||
public IFastest<T> AS(string tableName)
|
||||
{
|
||||
this.AsName = tableName;
|
||||
|
@ -8,6 +8,8 @@ namespace SqlSugar
|
||||
{
|
||||
public interface IFastest<T> where T:class,new()
|
||||
{
|
||||
IFastest<T> RemoveDataCache();
|
||||
IFastest<T> RemoveDataCache(string cacheKey);
|
||||
IFastest<T> AS(string tableName);
|
||||
IFastest<T> PageSize(int Size);
|
||||
int BulkCopy(List<T> datas);
|
||||
|
Loading…
Reference in New Issue
Block a user