mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
Add Db.Fastest.RemoveDataCache
This commit is contained in:
@@ -191,12 +191,12 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var title = isAdd ? "BulkCopy" : "BulkUpdate";
|
var title = isAdd ? "BulkCopy" : "BulkUpdate";
|
||||||
this.context.Ado.IsEnableLogEvent = isLog;
|
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)
|
private void Begin<Type>(List<Type> datas,bool isAdd)
|
||||||
{
|
{
|
||||||
var title = isAdd ? "BulkCopy" : "BulkUpdate";
|
var title = isAdd ? "BulkCopy" : "BulkUpdate";
|
||||||
|
@@ -161,5 +161,24 @@ namespace SqlSugar
|
|||||||
tempDataTable.TableName = dt.TableName;
|
tempDataTable.TableName = dt.TableName;
|
||||||
return tempDataTable;
|
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 string AsName { get; set; }
|
||||||
private int Size { 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)
|
public IFastest<T> AS(string tableName)
|
||||||
{
|
{
|
||||||
this.AsName = tableName;
|
this.AsName = tableName;
|
||||||
|
@@ -8,6 +8,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public interface IFastest<T> where T:class,new()
|
public interface IFastest<T> where T:class,new()
|
||||||
{
|
{
|
||||||
|
IFastest<T> RemoveDataCache();
|
||||||
|
IFastest<T> RemoveDataCache(string cacheKey);
|
||||||
IFastest<T> AS(string tableName);
|
IFastest<T> AS(string tableName);
|
||||||
IFastest<T> PageSize(int Size);
|
IFastest<T> PageSize(int Size);
|
||||||
int BulkCopy(List<T> datas);
|
int BulkCopy(List<T> datas);
|
||||||
|
Reference in New Issue
Block a user