mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
-
This commit is contained in:
@@ -28,6 +28,7 @@ namespace SqlSugar
|
||||
string sql = DeleteBuilder.ToSqlString();
|
||||
var paramters = DeleteBuilder.Parameters == null ? null : DeleteBuilder.Parameters.ToArray();
|
||||
RestoreMapping();
|
||||
AutoRemoveDataCache();
|
||||
return Db.ExecuteCommand(sql, paramters);
|
||||
}
|
||||
public bool ExecuteCommandHasChange()
|
||||
@@ -270,6 +271,17 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoRemoveDataCache()
|
||||
{
|
||||
var moreSetts = this.Context.CurrentConnectionConfig.MoreSettings;
|
||||
var extService = this.Context.CurrentConnectionConfig.ConfigureExternalServices;
|
||||
if (moreSetts != null && moreSetts.IsAutoRemoveDataCache && extService != null && extService.DataInfoCacheService != null)
|
||||
{
|
||||
this.RemoveDataCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IDeleteable<T> CopyDeleteable()
|
||||
{
|
||||
var asyncContext = this.Context.Utilities.CopyContext(true);
|
||||
|
@@ -32,6 +32,7 @@ namespace SqlSugar
|
||||
{
|
||||
InsertBuilder.IsReturnIdentity = false;
|
||||
PreToSql();
|
||||
AutoRemoveDataCache();
|
||||
string sql = InsertBuilder.ToSqlString();
|
||||
RestoreMapping();
|
||||
return Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
||||
@@ -41,6 +42,7 @@ namespace SqlSugar
|
||||
{
|
||||
InsertBuilder.IsReturnIdentity = true;
|
||||
PreToSql();
|
||||
AutoRemoveDataCache();
|
||||
string sql = InsertBuilder.ToSqlString();
|
||||
RestoreMapping();
|
||||
return new KeyValuePair<string, List<SugarParameter>>(sql, InsertBuilder.Parameters);
|
||||
@@ -49,6 +51,7 @@ namespace SqlSugar
|
||||
{
|
||||
InsertBuilder.IsReturnIdentity = true;
|
||||
PreToSql();
|
||||
AutoRemoveDataCache();
|
||||
string sql = InsertBuilder.ToSqlString();
|
||||
RestoreMapping();
|
||||
return Ado.GetInt(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
||||
@@ -57,6 +60,7 @@ namespace SqlSugar
|
||||
{
|
||||
InsertBuilder.IsReturnIdentity = true;
|
||||
PreToSql();
|
||||
AutoRemoveDataCache();
|
||||
string sql = InsertBuilder.ToSqlString();
|
||||
RestoreMapping();
|
||||
return Convert.ToInt64( Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()));
|
||||
@@ -194,6 +198,15 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Protected Methods
|
||||
private void AutoRemoveDataCache()
|
||||
{
|
||||
var moreSetts = this.Context.CurrentConnectionConfig.MoreSettings;
|
||||
var extService = this.Context.CurrentConnectionConfig.ConfigureExternalServices;
|
||||
if (moreSetts != null && moreSetts.IsAutoRemoveDataCache && extService != null && extService.DataInfoCacheService != null)
|
||||
{
|
||||
this.RemoveDataCache();
|
||||
}
|
||||
}
|
||||
protected virtual void PreToSql()
|
||||
{
|
||||
#region Identities
|
||||
|
@@ -28,6 +28,7 @@ namespace SqlSugar
|
||||
public virtual int ExecuteCommand()
|
||||
{
|
||||
PreToSql();
|
||||
AutoRemoveDataCache();
|
||||
Check.Exception(UpdateBuilder.WhereValues.IsNullOrEmpty() && GetPrimaryKeys().IsNullOrEmpty(), "You cannot have no primary key and no conditions");
|
||||
string sql = UpdateBuilder.ToSqlString();
|
||||
RestoreMapping();
|
||||
@@ -93,7 +94,15 @@ namespace SqlSugar
|
||||
UpdateBuilder.SetValues.Add(new KeyValuePair<string, string>(leftResultString, resultString));
|
||||
return this;
|
||||
}
|
||||
|
||||
private void AutoRemoveDataCache()
|
||||
{
|
||||
var moreSetts = this.Context.CurrentConnectionConfig.MoreSettings;
|
||||
var extService = this.Context.CurrentConnectionConfig.ConfigureExternalServices;
|
||||
if (moreSetts != null && moreSetts.IsAutoRemoveDataCache && extService!=null&& extService.DataInfoCacheService!=null)
|
||||
{
|
||||
this.RemoveDataCache();
|
||||
}
|
||||
}
|
||||
public KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||
{
|
||||
PreToSql();
|
||||
|
Reference in New Issue
Block a user