mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
PgSql difflog bug
This commit is contained in:
parent
859e7d34d4
commit
43d9f8caf3
@ -23,7 +23,7 @@ namespace OrmTest
|
|||||||
});
|
});
|
||||||
db.Aop.OnLogExecuted = (sql, pars) => //SQL executed event
|
db.Aop.OnLogExecuted = (sql, pars) => //SQL executed event
|
||||||
{
|
{
|
||||||
Console.WriteLine("OnLogExecuted"+sql);
|
Console.WriteLine("OnLogExecuted" + sql);
|
||||||
};
|
};
|
||||||
db.Aop.OnLogExecuting = (sql, pars) => //SQL executing event (pre-execution)
|
db.Aop.OnLogExecuting = (sql, pars) => //SQL executing event (pre-execution)
|
||||||
{
|
{
|
||||||
@ -46,14 +46,14 @@ namespace OrmTest
|
|||||||
var businessData = it.BusinessData;
|
var businessData = it.BusinessData;
|
||||||
var time = it.Time;
|
var time = it.Time;
|
||||||
var diffType = it.DiffType;//enum insert 、update and delete
|
var diffType = it.DiffType;//enum insert 、update and delete
|
||||||
Console.WriteLine(businessData);
|
//Console.WriteLine(businessData);
|
||||||
Console.WriteLine(editBeforeData[0].Columns[1].Value);
|
//Console.WriteLine(editBeforeData[0].Columns[1].Value);
|
||||||
Console.WriteLine("to");
|
//Console.WriteLine("to");
|
||||||
Console.WriteLine(editAfterData[0].Columns[1].Value);
|
//Console.WriteLine(editAfterData[0].Columns[1].Value);
|
||||||
//Write logic
|
//Write logic
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
db.Queryable<Order>().ToList();
|
db.Queryable<Order>().ToList();
|
||||||
db.Queryable<OrderItem>().ToList();
|
db.Queryable<OrderItem>().ToList();
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ namespace OrmTest
|
|||||||
var data = db.Queryable<Order>().First();
|
var data = db.Queryable<Order>().First();
|
||||||
data.Name = "changeName";
|
data.Name = "changeName";
|
||||||
db.Updateable(data).EnableDiffLogEvent("--update Order--").ExecuteCommand();
|
db.Updateable(data).EnableDiffLogEvent("--update Order--").ExecuteCommand();
|
||||||
|
db.Insertable(data).EnableDiffLogEvent("--inser Order--").ExecuteCommand();
|
||||||
Console.WriteLine("#### Aop End ####");
|
Console.WriteLine("#### Aop End ####");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -747,8 +747,16 @@ namespace SqlSugar
|
|||||||
foreach (var item in this.EntityInfo.Columns.Where(it => it.IsIgnore == false && GetPrimaryKeys().Any(pk => pk.Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase))))
|
foreach (var item in this.EntityInfo.Columns.Where(it => it.IsIgnore == false && GetPrimaryKeys().Any(pk => pk.Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase))))
|
||||||
{
|
{
|
||||||
var fielddName = item.DbColumnName;
|
var fielddName = item.DbColumnName;
|
||||||
var fieldValue = this.EntityInfo.Columns.FirstOrDefault(it => it.PropertyName == item.PropertyName).PropertyInfo.GetValue(this.InsertObjs.Last(), null).ObjToString();
|
var filedObject = this.EntityInfo.Columns.FirstOrDefault(it => it.PropertyName == item.PropertyName).PropertyInfo.GetValue(this.InsertObjs.Last(), null);
|
||||||
cons.Add(new ConditionalModel() { ConditionalType = ConditionalType.Equal, FieldName = fielddName, FieldValue = fieldValue });
|
var fieldValue = filedObject.ObjToString();
|
||||||
|
if (filedObject != null && filedObject.GetType() != typeof(string)&&this.Context.CurrentConnectionConfig.DbType==DbType.PostgreSQL)
|
||||||
|
{
|
||||||
|
cons.Add(new ConditionalModel() { ConditionalType = ConditionalType.Equal, FieldName = fielddName, FieldValue = fieldValue,FieldValueConvertFunc= it => UtilMethods.ChangeType2(it, filedObject.GetType()) });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cons.Add(new ConditionalModel() { ConditionalType = ConditionalType.Equal, FieldName = fielddName, FieldValue = fieldValue });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Check.Exception(cons.IsNullOrEmpty(), "Insertable.EnableDiffLogEvent need primary key");
|
Check.Exception(cons.IsNullOrEmpty(), "Insertable.EnableDiffLogEvent need primary key");
|
||||||
|
Loading…
Reference in New Issue
Block a user