mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-18 09:44:39 +08:00
Master Slave bug
This commit is contained in:
@@ -403,6 +403,8 @@ namespace SqlSugar
|
||||
{
|
||||
if (this.IsEnableDiffLogEvent)
|
||||
{
|
||||
var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
|
||||
this.Context.Ado.IsDisableMasterSlaveSeparation = true;
|
||||
var parameters = DeleteBuilder.Parameters;
|
||||
if (parameters == null)
|
||||
parameters = new List<SugarParameter>();
|
||||
@@ -410,6 +412,7 @@ namespace SqlSugar
|
||||
diffModel.Time = this.Context.Ado.SqlExecutionTime;
|
||||
if (this.Context.Ado.DiffLogEvent != null)
|
||||
this.Context.Ado.DiffLogEvent(diffModel);
|
||||
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||
}
|
||||
if (this.RemoveCacheFunc != null) {
|
||||
this.RemoveCacheFunc();
|
||||
@@ -420,12 +423,15 @@ namespace SqlSugar
|
||||
{
|
||||
if (this.IsEnableDiffLogEvent)
|
||||
{
|
||||
var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
|
||||
this.Context.Ado.IsDisableMasterSlaveSeparation = true;
|
||||
var parameters = DeleteBuilder.Parameters;
|
||||
if (parameters == null)
|
||||
parameters = new List<SugarParameter>();
|
||||
diffModel.BeforeData = GetDiffTable(sql, parameters);
|
||||
diffModel.Sql = sql;
|
||||
diffModel.Parameters = parameters.ToArray();
|
||||
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -456,6 +456,8 @@ namespace SqlSugar
|
||||
{
|
||||
if (this.IsEnableDiffLogEvent)
|
||||
{
|
||||
var isDisableMasterSlaveSeparation = this.Ado.IsDisableMasterSlaveSeparation;
|
||||
this.Ado.IsDisableMasterSlaveSeparation = true;
|
||||
var parameters = InsertBuilder.Parameters;
|
||||
if (parameters == null)
|
||||
parameters = new List<SugarParameter>();
|
||||
@@ -463,6 +465,7 @@ namespace SqlSugar
|
||||
diffModel.Time = this.Context.Ado.SqlExecutionTime;
|
||||
if (this.Context.Ado.DiffLogEvent != null)
|
||||
this.Context.Ado.DiffLogEvent(diffModel);
|
||||
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||
}
|
||||
if (this.RemoveCacheFunc != null)
|
||||
{
|
||||
@@ -473,12 +476,15 @@ namespace SqlSugar
|
||||
{
|
||||
if (this.IsEnableDiffLogEvent)
|
||||
{
|
||||
var isDisableMasterSlaveSeparation = this.Ado.IsDisableMasterSlaveSeparation;
|
||||
this.Ado.IsDisableMasterSlaveSeparation = true;
|
||||
var parameters = InsertBuilder.Parameters;
|
||||
if (parameters == null)
|
||||
parameters = new List<SugarParameter>();
|
||||
diffModel.BeforeData = null;
|
||||
diffModel.Sql = sql;
|
||||
diffModel.Parameters = parameters.ToArray();
|
||||
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||
}
|
||||
}
|
||||
private List<DiffLogTableInfo> GetDiffTable(string sql, long? identity)
|
||||
|
@@ -161,7 +161,7 @@ namespace SqlSugar
|
||||
public IUpdateable<T> WhereColumns(Expression<Func<T, object>> columns)
|
||||
{
|
||||
this.IsWhereColumns = true;
|
||||
Check.Exception(UpdateParameterIsNull==true, "Updateable<T>().Updateable is error,Use Updateable(obj).WhereColumns");
|
||||
Check.Exception(UpdateParameterIsNull == true, "Updateable<T>().Updateable is error,Use Updateable(obj).WhereColumns");
|
||||
var whereColumns = UpdateBuilder.GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => this.SqlBuilder.GetNoTranslationColumnName(it)).ToList();
|
||||
if (this.WhereColumnList == null) this.WhereColumnList = new List<string>();
|
||||
foreach (var item in whereColumns)
|
||||
@@ -177,7 +177,7 @@ namespace SqlSugar
|
||||
return this;
|
||||
}
|
||||
|
||||
public IUpdateable<T> WhereColumns(string [] columnNames)
|
||||
public IUpdateable<T> WhereColumns(string[] columnNames)
|
||||
{
|
||||
if (this.WhereColumnList == null) this.WhereColumnList = new List<string>();
|
||||
foreach (var columnName in columnNames)
|
||||
@@ -218,7 +218,7 @@ namespace SqlSugar
|
||||
|
||||
public IUpdateable<T> UpdateColumns(string[] columns)
|
||||
{
|
||||
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => GetPrimaryKeys().Select(iit=>iit.ToLower()).Contains(it.DbColumnName.ToLower()) || columns.Contains(it.PropertyName, StringComparer.OrdinalIgnoreCase)).ToList();
|
||||
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => GetPrimaryKeys().Select(iit => iit.ToLower()).Contains(it.DbColumnName.ToLower()) || columns.Contains(it.PropertyName, StringComparer.OrdinalIgnoreCase)).ToList();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -411,10 +411,11 @@ namespace SqlSugar
|
||||
private void PreToSql()
|
||||
{
|
||||
UpdateBuilder.PrimaryKeys = GetPrimaryKeys();
|
||||
if (this.IsWhereColumns) {
|
||||
if (this.IsWhereColumns)
|
||||
{
|
||||
foreach (var pkName in UpdateBuilder.PrimaryKeys)
|
||||
{
|
||||
var isContains=this.UpdateBuilder.DbColumnInfoList.Select(it => it.DbColumnName.ToLower()).Contains(pkName.ToLower());
|
||||
var isContains = this.UpdateBuilder.DbColumnInfoList.Select(it => it.DbColumnName.ToLower()).Contains(pkName.ToLower());
|
||||
Check.Exception(isContains == false, "Use UpdateColumns().WhereColumn() ,UpdateColumns need {0}", pkName);
|
||||
}
|
||||
}
|
||||
@@ -609,6 +610,8 @@ namespace SqlSugar
|
||||
{
|
||||
if (this.IsEnableDiffLogEvent)
|
||||
{
|
||||
var isDisableMasterSlaveSeparation = this.Ado.IsDisableMasterSlaveSeparation;
|
||||
this.Ado.IsDisableMasterSlaveSeparation = true;
|
||||
var parameters = UpdateBuilder.Parameters;
|
||||
if (parameters == null)
|
||||
parameters = new List<SugarParameter>();
|
||||
@@ -616,8 +619,10 @@ namespace SqlSugar
|
||||
diffModel.Time = this.Context.Ado.SqlExecutionTime;
|
||||
if (this.Context.Ado.DiffLogEvent != null)
|
||||
this.Context.Ado.DiffLogEvent(diffModel);
|
||||
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||
}
|
||||
if (this.RemoveCacheFunc != null) {
|
||||
if (this.RemoveCacheFunc != null)
|
||||
{
|
||||
this.RemoveCacheFunc();
|
||||
}
|
||||
}
|
||||
@@ -626,12 +631,15 @@ namespace SqlSugar
|
||||
{
|
||||
if (this.IsEnableDiffLogEvent)
|
||||
{
|
||||
var isDisableMasterSlaveSeparation = this.Ado.IsDisableMasterSlaveSeparation;
|
||||
this.Ado.IsDisableMasterSlaveSeparation = true;
|
||||
var parameters = UpdateBuilder.Parameters;
|
||||
if (parameters == null)
|
||||
parameters = new List<SugarParameter>();
|
||||
diffModel.BeforeData = GetDiffTable(sql, parameters);
|
||||
diffModel.Sql = sql;
|
||||
diffModel.Parameters = parameters.ToArray();
|
||||
this.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user