mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-30 22:10:22 +08:00
Update DiffLog
This commit is contained in:
parent
d0e786324b
commit
d8a8367416
@ -359,7 +359,7 @@ namespace SqlSugar
|
||||
|
||||
public IInsertable<T> EnableDiffLogEvent(object businessData = null)
|
||||
{
|
||||
Check.Exception(this.InsertObjs.HasValue() && this.InsertObjs.Count() > 1, "DiffLog does not support batch operations");
|
||||
//Check.Exception(this.InsertObjs.HasValue() && this.InsertObjs.Count() > 1, "DiffLog does not support batch operations");
|
||||
diffModel = new DiffLogModel();
|
||||
this.IsEnableDiffLogEvent = true;
|
||||
diffModel.BusinessData = businessData;
|
||||
@ -769,6 +769,45 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
private List<DiffLogTableInfo> GetDiffTable(string sql, long? identity)
|
||||
{
|
||||
|
||||
if (GetIdentityKeys().HasValue() && this.InsertObjs.Count() > 1)
|
||||
{
|
||||
return GetDiffTableByEntity();
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetDiffTableBySql(identity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<DiffLogTableInfo> GetDiffTableByEntity()
|
||||
{
|
||||
List<SugarParameter> parameters = new List<SugarParameter>();
|
||||
List<DiffLogTableInfo> result = new List<DiffLogTableInfo>();
|
||||
var dt2 = this.Context.Utilities.ListToDataTable<T>(this.InsertObjs.ToList());
|
||||
foreach (DataRow row in dt2.Rows)
|
||||
{
|
||||
DiffLogTableInfo item = new DiffLogTableInfo();
|
||||
item.TableDescription = this.EntityInfo.TableDescription;
|
||||
item.TableName = this.EntityInfo.DbTableName;
|
||||
item.Columns = new List<DiffLogColumnInfo>();
|
||||
foreach (DataColumn col in dt2.Columns)
|
||||
{
|
||||
|
||||
DiffLogColumnInfo addItem = new DiffLogColumnInfo();
|
||||
addItem.Value = row[col.ColumnName];
|
||||
addItem.ColumnName = col.ColumnName;
|
||||
addItem.ColumnDescription = this.EntityInfo.Columns.Where(it => it.DbColumnName != null).FirstOrDefault(it => it.DbColumnName.Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase))?.ColumnDescription;
|
||||
item.Columns.Add(addItem);
|
||||
}
|
||||
result.Add(item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<DiffLogTableInfo> GetDiffTableBySql(long? identity)
|
||||
{
|
||||
List<SugarParameter> parameters = new List<SugarParameter>();
|
||||
List<DiffLogTableInfo> result = new List<DiffLogTableInfo>();
|
||||
@ -834,7 +873,6 @@ namespace SqlSugar
|
||||
}).ToList();
|
||||
return new List<DiffLogTableInfo>() { diffTable };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IInsertable<T> CallEntityMethod(Expression<Action<T>> method)
|
||||
|
Loading…
Reference in New Issue
Block a user