diff --git a/Unit-of-Work.md b/Unit-of-Work.md index d97af2b..f93f08a 100644 --- a/Unit-of-Work.md +++ b/Unit-of-Work.md @@ -43,14 +43,14 @@ The `uow.GetOrBeginTransaction()` method can get the transaction object. public interface IUnitOfWork : IDisposable { /// - /// 该对象 Select/Delete/Insert/Update/InsertOrUpdate 与工作单元事务保持一致,可省略传递 WithTransaction + /// The object Select/Delete/Insert/Update/InsertOrUpdate is consistent with the unit of work transaction and can be omitted to pass WithTransaction /// IFreeSql Orm { get; } /// - /// 开启事务,或者返回已开启的事务 + /// Open the transaction, or return to the opened transaction /// - /// 若未开启事务,则开启 + /// If the transaction is not opened, then open /// DbTransaction GetOrBeginTransaction(bool isCreate = true); @@ -61,15 +61,15 @@ public interface IUnitOfWork : IDisposable void Rollback(); /// - /// 工作单元内的实体变化跟踪 + /// Entity change tracking within the unit of work /// DbContext.EntityChangeReport EntityChangeReport { get; } } ``` -## 实体变化事件 +## Entity Changing Event -全局设置: +Global Settings: ```csharp fsql.SetDbContextOptions(opt => { @@ -79,7 +79,7 @@ fsql.SetDbContextOptions(opt => { }); ``` -单独设置: +Individual settings: ```csharp var uow = fsql.CreateUnitOfWork(); @@ -88,26 +88,26 @@ uow.OnEntityChange = report => { }; ``` -参数 report 是一个 List 集合,集合元素的类型定义如下: +The parameter `report` is a list collection, and the type of the collection elements is defined as follows: ```csharp public class ChangeInfo { public object Object { get; set; } public EntityChangeType Type { get; set; } /// - /// Type = Update 的时候,获取更新之前的对象 + /// When Type = Update, get the object before the update /// public object BeforeObject { get; set; } } public enum EntityChangeType { Insert, Update, Delete, SqlRaw } ``` -| 变化类型 | 说明 | +| Type of Change | Description | | -- | -- | -| Insert | 实体对象被插入 | -| Update | 实体对象被更新 | -| Delete | 实体对象被删除 | -| SqlRaw | 执行了SQL语句 | +| Insert | The entity object is inserted | +| Update | The entity object is updated | +| Delete | The entity object is deleted | +| SqlRaw | SQL statement executed | SqlRaw 目前有两处地方比较特殊: - 多对多联级更新导航属性的时候,对中间表的全部删除操作; @@ -118,12 +118,12 @@ int Delete(Expression> predicate); DbContext.SaveChanges,或者 Repository 对实体的 Insert/Update/Delete,或者 UnitOfWork.Commit 操作都会最多触发一次该事件。 -## 参考资料 +## Reference -- [《租户》](%e7%a7%9f%e6%88%b7) -- [《读写分离》](%e8%af%bb%e5%86%99%e5%88%86%e7%a6%bb) -- [《分表、分库》](%e5%88%86%e8%a1%a8%e5%88%86%e5%ba%93) -- [《仓储层Repository》](Repository) -- [《过滤器、全局过滤器》](%e8%bf%87%e6%bb%a4%e5%99%a8) -- [《AOP》](AOP) -- [《DbContext》](DbContext) \ No newline at end of file +- [《Tenant》](Tenant) +- [《Using Read/Write Separation》](Using-Read-Write-Separation) +- [《Sharding Tables and Database》](Sharding-Tables-and-Database) +- [《Repository Layer》](Repository-Layer) +- [《Filters and Global Filters》](Filters-and-Global-Filters) +- [《AOP》](Aspect-Oriented-Programming) +- [《DbContext》](Batabase-Context) \ No newline at end of file