Add RemoveDataCache

This commit is contained in:
sunkaixuan 2017-10-10 19:58:57 +08:00
parent 228db65a9a
commit a2ad14b3bc
9 changed files with 31 additions and 5 deletions

View File

@ -49,7 +49,7 @@ namespace SqlSugar
Task<bool> result = new Task<bool>(() =>
{
IDeleteable<T> asyncDeleteable = CopyDeleteable();
return asyncDeleteable.ExecuteCommand()>0;
return asyncDeleteable.ExecuteCommand() > 0;
});
result.Start();
return result;
@ -173,6 +173,14 @@ namespace SqlSugar
DeleteBuilder.Parameters.AddRange(parameters);
return this;
}
public IDeleteable<T> RemoveDataCache()
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
return this;
}
public IDeleteable<T> In<PkType>(List<PkType> primaryKeyValues)
{
if (primaryKeyValues == null || primaryKeyValues.Count() == 0)

View File

@ -184,6 +184,13 @@ namespace SqlSugar
this.InsertBuilder.IsNoInsertNull = isNoInsertNull;
return this;
}
public IInsertable<T> RemoveDataCache()
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
return this;
}
#endregion
#region Protected Methods

View File

@ -1032,7 +1032,7 @@ namespace SqlSugar
var sqlObj = this.ToSql();
if (IsCache)
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCache;
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
result = CacheSchemeMain.GetOrCreate<List<TResult>>(cacheService, this.QueryBuilder, () => { return GetData<TResult>(sqlObj); }, CacheTime, this.Context);
}
else

View File

@ -174,6 +174,7 @@ namespace SqlSugar
UpdateBuilder.WhereValues.Add(expResult.GetResultString());
return this;
}
public IUpdateable<T> With(string lockString)
{
if (this.Context.CurrentConnectionConfig.DbType == DbType.SqlServer)
@ -181,6 +182,13 @@ namespace SqlSugar
return this;
}
public IUpdateable<T> RemoveDataCache()
{
var cacheService = this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService;
CacheSchemeMain.RemoveCache(cacheService, this.Context.EntityMaintenance.GetTableName<T>());
return this;
}
internal void Init()
{
this.UpdateBuilder.TableName = EntityInfo.EntityName;

View File

@ -49,7 +49,7 @@ namespace SqlSugar
set{ _SerializeService = value;}
}
public ICacheService ReflectionInoCache
public ICacheService ReflectionInoCacheService
{
get
{
@ -61,7 +61,7 @@ namespace SqlSugar
set{_ReflectionInoCache = value;}
}
public ICacheService DataInfoCache
public ICacheService DataInfoCacheService
{
get
{

View File

@ -272,7 +272,7 @@ namespace SqlSugar
#region Cache
public ICacheService GetReflectionInoCacheInstance()
{
return Context.CurrentConnectionConfig.ConfigureExternalServices.ReflectionInoCache;
return Context.CurrentConnectionConfig.ConfigureExternalServices.ReflectionInoCacheService;
}
public void RemoveCacheAll()

View File

@ -26,6 +26,7 @@ namespace SqlSugar
IDeleteable<T> Where(string whereString, SugarParameter parameter);
IDeleteable<T> Where(string whereString, SugarParameter[] parameters);
IDeleteable<T> Where(string whereString, List<SugarParameter> parameters);
IDeleteable<T> RemoveDataCache();
KeyValuePair<string, List<SugarParameter>> ToSql();
}
}

View File

@ -30,6 +30,7 @@ namespace SqlSugar
IUpdateable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IUpdateable<T> IgnoreColumns(Func<string, bool> ignoreColumMethod);
IUpdateable<T> ReSetValue(Expression<Func<T, bool>> setValueExpression);
IUpdateable<T> RemoveDataCache();
KeyValuePair<string,List<SugarParameter>> ToSql();
}
}

View File

@ -27,6 +27,7 @@ namespace SqlSugar
IInsertable<T> IgnoreColumns(Expression<Func<T, object>> columns);
IInsertable<T> IgnoreColumns(Func<string,bool> ignoreColumMethod);
IInsertable<T> Where(bool isInsertNull, bool isOffIdentity = false);
IInsertable<T> RemoveDataCache();
KeyValuePair<string, List<SugarParameter>> ToSql();
}
}