Add English comments.

This commit is contained in:
AlexLEWIS 2021-08-06 17:23:52 +08:00
parent 73d2bfc680
commit 6789c3f3ee
2 changed files with 39 additions and 22 deletions

View File

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

View File

@ -12,8 +12,12 @@ using System.Threading.Tasks;
namespace FreeSql
{
/// <summary>
/// Entity base class, including CreateTime/UpdateTime/IsDeleted, the async CRUD methods, and ID primary key definition.
/// <para></para>
/// 包括 CreateTime/UpdateTime/IsDeleted、CRUD 异步方法、以及 ID 主键定义 的实体基类
/// <para></para>
/// When TKey is int/long, the Id is set to be an auto-incremented primary key
/// <para></para>
/// 当 TKey 为 int/long 时Id 主键被设为自增值主键
/// </summary>
/// <typeparam name="TEntity"></typeparam>
@ -29,6 +33,7 @@ namespace FreeSql
}
/// <summary>
/// Primary key <br />
/// 主键
/// </summary>
[Column(Position = 1)]
@ -36,6 +41,7 @@ namespace FreeSql
#if !NET40
/// <summary>
/// Get data based on the value of the primary key <br />
/// 根据主键值获取数据
/// </summary>
/// <param name="id"></param>
@ -50,6 +56,8 @@ namespace FreeSql
}
/// <summary>
/// Entity base class, including CreateTime/UpdateTime/IsDeleted, and async CRUD methods.
/// <para></para>
/// 包括 CreateTime/UpdateTime/IsDeleted、以及 CRUD 异步方法的实体基类
/// </summary>
/// <typeparam name="TEntity"></typeparam>
@ -72,9 +80,10 @@ namespace FreeSql
}
/// <summary>
/// To delete data <br />
/// 删除数据
/// </summary>
/// <param name="physicalDelete">是否物理删除</param>
/// <param name="physicalDelete">To flag whether to delete the physical level of the data</param>
/// <returns></returns>
public virtual async Task<bool> DeleteAsync(bool physicalDelete = false)
{
@ -89,12 +98,14 @@ namespace FreeSql
}
/// <summary>
/// To recover deleted data <br />
/// 恢复删除的数据
/// </summary>
/// <returns></returns>
public virtual Task<bool> RestoreAsync() => UpdateIsDeletedAsync(false);
/// <summary>
/// To update data <br />
/// 更新数据
/// </summary>
/// <returns></returns>
@ -113,41 +124,38 @@ namespace FreeSql
}
/// <summary>
/// To insert data <br />
/// 插入数据
/// </summary>
public virtual Task<TEntity> InsertAsync()
{
CreateTime = DateTime.Now;
if (Repository is null)
Repository = Orm.GetRepository<TEntity>();
Repository ??= Orm.GetRepository<TEntity>();
Repository.UnitOfWork = _resolveUow?.Invoke();
return Repository.InsertAsync(this as TEntity);
}
/// <summary>
/// To insert or update data <br />
/// 更新或插入
/// </summary>
/// <returns></returns>
public virtual Task<TEntity> SaveAsync()
{
UpdateTime = DateTime.Now;
if (Repository is null)
Repository = Orm.GetRepository<TEntity>();
Repository ??= Orm.GetRepository<TEntity>();
Repository.UnitOfWork = _resolveUow?.Invoke();
return Repository.InsertOrUpdateAsync(this as TEntity);
}
/// <summary>
/// To completely save the navigation properties of the entity in the form of sub-tables. <br />
/// 【完整】保存导航属性,子表
/// </summary>
/// <param name="navigatePropertyName">导航属性名</param>
/// <param name="navigatePropertyName">Navigation property name</param>
public virtual Task SaveManyAsync(string navigatePropertyName)
{
if (Repository is null)
Repository = Orm.GetRepository<TEntity>();
Repository ??= Orm.GetRepository<TEntity>();
Repository.UnitOfWork = _resolveUow?.Invoke();
return Repository.SaveManyAsync(this as TEntity, navigatePropertyName);
}