mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 FreeSql.DbContext 实体对象的变化事件;
> 文档:https://github.com/2881099/FreeSql/wiki/DbContext#%E5%AE%9E%E4%BD%93%E5%8F%98%E5%8C%96%E4%BA%8B%E4%BB%B6 - 补充 Aop.CurdBefore 事件参数 Table 实体类型的元数据;
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using SafeObjectPool;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Threading;
|
||||
@ -32,6 +33,7 @@ namespace FreeSql
|
||||
#if ns20
|
||||
Current.Value = null;
|
||||
#endif
|
||||
EntityChangeReport.Clear();
|
||||
}
|
||||
|
||||
public bool Enable { get; private set; } = true;
|
||||
@ -76,7 +78,11 @@ namespace FreeSql
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_tran != null) _tran.Commit();
|
||||
if (_tran != null)
|
||||
{
|
||||
_tran.Commit();
|
||||
OnEntityChange?.Invoke(EntityChangeReport);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -94,6 +100,13 @@ namespace FreeSql
|
||||
ReturnObject();
|
||||
}
|
||||
}
|
||||
|
||||
public Action<List<DbContext.EntityChangeInfo>> OnEntityChange { get; set; }
|
||||
/// <summary>
|
||||
/// 工作单元的实体变化记录
|
||||
/// </summary>
|
||||
public List<DbContext.EntityChangeInfo> EntityChangeReport { get; } = new List<DbContext.EntityChangeInfo>();
|
||||
|
||||
~UnitOfWork()
|
||||
{
|
||||
this.Dispose();
|
||||
|
Reference in New Issue
Block a user