|
|
@ -4,7 +4,7 @@ using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
using SqlSugar; |
|
|
|
namespace OrmTest |
|
|
|
{ |
|
|
|
public class DemoB_Aop |
|
|
@ -38,11 +38,32 @@ namespace OrmTest |
|
|
|
return new KeyValuePair<string, SugarParameter[]>(sql, pars); |
|
|
|
}; |
|
|
|
|
|
|
|
db.Aop.OnDiffLogEvent = it =>//Get data changes
|
|
|
|
{ |
|
|
|
var editBeforeData = it.BeforeData; |
|
|
|
var editAfterData = it.AfterData; |
|
|
|
var sql = it.Sql; |
|
|
|
var parameter = it.Parameters; |
|
|
|
var businessData = it.BusinessData; |
|
|
|
var time = it.Time; |
|
|
|
var diffType = it.DiffType;//enum insert 、update and delete
|
|
|
|
Console.WriteLine(editBeforeData[0].Columns[1].Value); |
|
|
|
Console.WriteLine("to"); |
|
|
|
Console.WriteLine(editAfterData[0].Columns[1].Value); |
|
|
|
//Write logic
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.Queryable<Order>().ToList(); |
|
|
|
db.Queryable<OrderItem>().ToList(); |
|
|
|
|
|
|
|
//OnDiffLogEvent
|
|
|
|
var data = db.Queryable<Order>().First(); |
|
|
|
data.Name = "changeName"; |
|
|
|
db.Updateable(data).EnableDiffLogEvent().ExecuteCommand(); |
|
|
|
|
|
|
|
Console.WriteLine("#### Aop End ####"); |
|
|
|
} |
|
|
|
} |
|
|
|