diff --git a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntity.cs b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntity.cs index 76d2d2a5..8986e5b5 100644 --- a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntity.cs +++ b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntity.cs @@ -13,8 +13,12 @@ using System.Threading.Tasks; namespace FreeSql { /// + /// Entity base class, including CreateTime/UpdateTime/IsDeleted, the CRUD methods, and ID primary key definition. + /// /// 包括 CreateTime/UpdateTime/IsDeleted、CRUD 方法、以及 ID 主键定义 的实体基类 /// + /// When TKey is int/long, the Id is set to be an auto-incremented primary key + /// /// 当 TKey 为 int/long 时,Id 主键被设为自增值主键 /// /// @@ -30,6 +34,7 @@ namespace FreeSql } /// + /// Primary key
/// 主键 ///
[Column(Position = 1)] @@ -37,6 +42,7 @@ namespace FreeSql #if !NET40 /// + /// Get data based on the value of the primary key
/// 根据主键值获取数据 ///
/// @@ -50,6 +56,7 @@ namespace FreeSql #endif /// + /// Get data based on the value of the primary key
/// 根据主键值获取数据 ///
/// @@ -63,6 +70,8 @@ namespace FreeSql } /// + /// Entity base class, including CreateTime/UpdateTime/IsDeleted, and sync/async CRUD methods. + /// /// 包括 CreateTime/UpdateTime/IsDeleted、以及 CRUD 异步和同步方法的实体基类 /// /// @@ -84,9 +93,10 @@ namespace FreeSql } /// + /// To delete data
/// 删除数据 ///
- /// 是否物理删除 + /// To flag whether to delete the physical level of the data /// public virtual bool Delete(bool physicalDelete = false) { @@ -101,12 +111,14 @@ namespace FreeSql } /// + /// To recover deleted data
/// 恢复删除的数据 ///
/// public virtual bool Restore() => UpdateIsDeleted(false); /// + /// To update data
/// 更新数据 ///
/// @@ -125,41 +137,38 @@ namespace FreeSql } /// + /// To insert data
/// 插入数据 ///
public virtual TEntity Insert() { CreateTime = DateTime.Now; - if (Repository is null) - Repository = Orm.GetRepository(); - + Repository ??= Orm.GetRepository(); Repository.UnitOfWork = _resolveUow?.Invoke(); return Repository.Insert(this as TEntity); } /// + /// To insert or update data
/// 更新或插入 ///
/// public virtual TEntity Save() { UpdateTime = DateTime.Now; - if (Repository is null) - Repository = Orm.GetRepository(); - + Repository ??= Orm.GetRepository(); Repository.UnitOfWork = _resolveUow?.Invoke(); return Repository.InsertOrUpdate(this as TEntity); } /// + /// To completely save the navigation properties of the entity in the form of sub-tables.
/// 【完整】保存导航属性,子表 ///
- /// 导航属性名 + /// Navigation property name public virtual void SaveMany(string navigatePropertyName) { - if (Repository is null) - Repository = Orm.GetRepository(); - + Repository ??= Orm.GetRepository(); Repository.UnitOfWork = _resolveUow?.Invoke(); Repository.SaveMany(this as TEntity, navigatePropertyName); } diff --git a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityAsync.cs b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityAsync.cs index 3821a812..58f1300e 100644 --- a/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityAsync.cs +++ b/Extensions/FreeSql.Extensions.BaseEntity/BaseEntityAsync.cs @@ -12,8 +12,12 @@ using System.Threading.Tasks; namespace FreeSql { /// + /// Entity base class, including CreateTime/UpdateTime/IsDeleted, the async CRUD methods, and ID primary key definition. + /// /// 包括 CreateTime/UpdateTime/IsDeleted、CRUD 异步方法、以及 ID 主键定义 的实体基类 /// + /// When TKey is int/long, the Id is set to be an auto-incremented primary key + /// /// 当 TKey 为 int/long 时,Id 主键被设为自增值主键 /// /// @@ -29,6 +33,7 @@ namespace FreeSql } /// + /// Primary key
/// 主键 ///
[Column(Position = 1)] @@ -36,6 +41,7 @@ namespace FreeSql #if !NET40 /// + /// Get data based on the value of the primary key
/// 根据主键值获取数据 ///
/// @@ -50,6 +56,8 @@ namespace FreeSql } /// + /// Entity base class, including CreateTime/UpdateTime/IsDeleted, and async CRUD methods. + /// /// 包括 CreateTime/UpdateTime/IsDeleted、以及 CRUD 异步方法的实体基类 /// /// @@ -72,9 +80,10 @@ namespace FreeSql } /// + /// To delete data
/// 删除数据 ///
- /// 是否物理删除 + /// To flag whether to delete the physical level of the data /// public virtual async Task DeleteAsync(bool physicalDelete = false) { @@ -89,12 +98,14 @@ namespace FreeSql } /// + /// To recover deleted data
/// 恢复删除的数据 ///
/// public virtual Task RestoreAsync() => UpdateIsDeletedAsync(false); /// + /// To update data
/// 更新数据 ///
/// @@ -113,41 +124,38 @@ namespace FreeSql } /// + /// To insert data
/// 插入数据 ///
public virtual Task InsertAsync() { CreateTime = DateTime.Now; - if (Repository is null) - Repository = Orm.GetRepository(); - + Repository ??= Orm.GetRepository(); Repository.UnitOfWork = _resolveUow?.Invoke(); return Repository.InsertAsync(this as TEntity); } /// + /// To insert or update data
/// 更新或插入 ///
/// public virtual Task SaveAsync() { UpdateTime = DateTime.Now; - if (Repository is null) - Repository = Orm.GetRepository(); - + Repository ??= Orm.GetRepository(); Repository.UnitOfWork = _resolveUow?.Invoke(); return Repository.InsertOrUpdateAsync(this as TEntity); } /// + /// To completely save the navigation properties of the entity in the form of sub-tables.
/// 【完整】保存导航属性,子表 ///
- /// 导航属性名 + /// Navigation property name public virtual Task SaveManyAsync(string navigatePropertyName) { - if (Repository is null) - Repository = Orm.GetRepository(); - + Repository ??= Orm.GetRepository(); Repository.UnitOfWork = _resolveUow?.Invoke(); return Repository.SaveManyAsync(this as TEntity, navigatePropertyName); }