mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
Add English comments.
This commit is contained in:
parent
73d2bfc680
commit
6789c3f3ee
@ -13,8 +13,12 @@ using System.Threading.Tasks;
|
|||||||
namespace FreeSql
|
namespace FreeSql
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Entity base class, including CreateTime/UpdateTime/IsDeleted, the CRUD methods, and ID primary key definition.
|
||||||
|
/// <para></para>
|
||||||
/// 包括 CreateTime/UpdateTime/IsDeleted、CRUD 方法、以及 ID 主键定义 的实体基类
|
/// 包括 CreateTime/UpdateTime/IsDeleted、CRUD 方法、以及 ID 主键定义 的实体基类
|
||||||
/// <para></para>
|
/// <para></para>
|
||||||
|
/// When TKey is int/long, the Id is set to be an auto-incremented primary key
|
||||||
|
/// <para></para>
|
||||||
/// 当 TKey 为 int/long 时,Id 主键被设为自增值主键
|
/// 当 TKey 为 int/long 时,Id 主键被设为自增值主键
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TEntity"></typeparam>
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
@ -30,6 +34,7 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Primary key <br />
|
||||||
/// 主键
|
/// 主键
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column(Position = 1)]
|
[Column(Position = 1)]
|
||||||
@ -37,6 +42,7 @@ namespace FreeSql
|
|||||||
|
|
||||||
#if !NET40
|
#if !NET40
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Get data based on the value of the primary key <br />
|
||||||
/// 根据主键值获取数据
|
/// 根据主键值获取数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
@ -50,6 +56,7 @@ namespace FreeSql
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Get data based on the value of the primary key <br />
|
||||||
/// 根据主键值获取数据
|
/// 根据主键值获取数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
@ -63,6 +70,8 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Entity base class, including CreateTime/UpdateTime/IsDeleted, and sync/async CRUD methods.
|
||||||
|
/// <para></para>
|
||||||
/// 包括 CreateTime/UpdateTime/IsDeleted、以及 CRUD 异步和同步方法的实体基类
|
/// 包括 CreateTime/UpdateTime/IsDeleted、以及 CRUD 异步和同步方法的实体基类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TEntity"></typeparam>
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
@ -84,9 +93,10 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To delete data <br />
|
||||||
/// 删除数据
|
/// 删除数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="physicalDelete">是否物理删除</param>
|
/// <param name="physicalDelete">To flag whether to delete the physical level of the data</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool Delete(bool physicalDelete = false)
|
public virtual bool Delete(bool physicalDelete = false)
|
||||||
{
|
{
|
||||||
@ -101,12 +111,14 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To recover deleted data <br />
|
||||||
/// 恢复删除的数据
|
/// 恢复删除的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool Restore() => UpdateIsDeleted(false);
|
public virtual bool Restore() => UpdateIsDeleted(false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To update data <br />
|
||||||
/// 更新数据
|
/// 更新数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -125,41 +137,38 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To insert data <br />
|
||||||
/// 插入数据
|
/// 插入数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual TEntity Insert()
|
public virtual TEntity Insert()
|
||||||
{
|
{
|
||||||
CreateTime = DateTime.Now;
|
CreateTime = DateTime.Now;
|
||||||
if (Repository is null)
|
Repository ??= Orm.GetRepository<TEntity>();
|
||||||
Repository = Orm.GetRepository<TEntity>();
|
|
||||||
|
|
||||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||||
return Repository.Insert(this as TEntity);
|
return Repository.Insert(this as TEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To insert or update data <br />
|
||||||
/// 更新或插入
|
/// 更新或插入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual TEntity Save()
|
public virtual TEntity Save()
|
||||||
{
|
{
|
||||||
UpdateTime = DateTime.Now;
|
UpdateTime = DateTime.Now;
|
||||||
if (Repository is null)
|
Repository ??= Orm.GetRepository<TEntity>();
|
||||||
Repository = Orm.GetRepository<TEntity>();
|
|
||||||
|
|
||||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||||
return Repository.InsertOrUpdate(this as TEntity);
|
return Repository.InsertOrUpdate(this as TEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To completely save the navigation properties of the entity in the form of sub-tables. <br />
|
||||||
/// 【完整】保存导航属性,子表
|
/// 【完整】保存导航属性,子表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="navigatePropertyName">导航属性名</param>
|
/// <param name="navigatePropertyName">Navigation property name</param>
|
||||||
public virtual void SaveMany(string navigatePropertyName)
|
public virtual void SaveMany(string navigatePropertyName)
|
||||||
{
|
{
|
||||||
if (Repository is null)
|
Repository ??= Orm.GetRepository<TEntity>();
|
||||||
Repository = Orm.GetRepository<TEntity>();
|
|
||||||
|
|
||||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||||
Repository.SaveMany(this as TEntity, navigatePropertyName);
|
Repository.SaveMany(this as TEntity, navigatePropertyName);
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,12 @@ using System.Threading.Tasks;
|
|||||||
namespace FreeSql
|
namespace FreeSql
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Entity base class, including CreateTime/UpdateTime/IsDeleted, the async CRUD methods, and ID primary key definition.
|
||||||
|
/// <para></para>
|
||||||
/// 包括 CreateTime/UpdateTime/IsDeleted、CRUD 异步方法、以及 ID 主键定义 的实体基类
|
/// 包括 CreateTime/UpdateTime/IsDeleted、CRUD 异步方法、以及 ID 主键定义 的实体基类
|
||||||
/// <para></para>
|
/// <para></para>
|
||||||
|
/// When TKey is int/long, the Id is set to be an auto-incremented primary key
|
||||||
|
/// <para></para>
|
||||||
/// 当 TKey 为 int/long 时,Id 主键被设为自增值主键
|
/// 当 TKey 为 int/long 时,Id 主键被设为自增值主键
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TEntity"></typeparam>
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
@ -29,6 +33,7 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Primary key <br />
|
||||||
/// 主键
|
/// 主键
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column(Position = 1)]
|
[Column(Position = 1)]
|
||||||
@ -36,6 +41,7 @@ namespace FreeSql
|
|||||||
|
|
||||||
#if !NET40
|
#if !NET40
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Get data based on the value of the primary key <br />
|
||||||
/// 根据主键值获取数据
|
/// 根据主键值获取数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
@ -50,6 +56,8 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Entity base class, including CreateTime/UpdateTime/IsDeleted, and async CRUD methods.
|
||||||
|
/// <para></para>
|
||||||
/// 包括 CreateTime/UpdateTime/IsDeleted、以及 CRUD 异步方法的实体基类
|
/// 包括 CreateTime/UpdateTime/IsDeleted、以及 CRUD 异步方法的实体基类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TEntity"></typeparam>
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
@ -72,9 +80,10 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To delete data <br />
|
||||||
/// 删除数据
|
/// 删除数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="physicalDelete">是否物理删除</param>
|
/// <param name="physicalDelete">To flag whether to delete the physical level of the data</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual async Task<bool> DeleteAsync(bool physicalDelete = false)
|
public virtual async Task<bool> DeleteAsync(bool physicalDelete = false)
|
||||||
{
|
{
|
||||||
@ -89,12 +98,14 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To recover deleted data <br />
|
||||||
/// 恢复删除的数据
|
/// 恢复删除的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual Task<bool> RestoreAsync() => UpdateIsDeletedAsync(false);
|
public virtual Task<bool> RestoreAsync() => UpdateIsDeletedAsync(false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To update data <br />
|
||||||
/// 更新数据
|
/// 更新数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -113,41 +124,38 @@ namespace FreeSql
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To insert data <br />
|
||||||
/// 插入数据
|
/// 插入数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Task<TEntity> InsertAsync()
|
public virtual Task<TEntity> InsertAsync()
|
||||||
{
|
{
|
||||||
CreateTime = DateTime.Now;
|
CreateTime = DateTime.Now;
|
||||||
if (Repository is null)
|
Repository ??= Orm.GetRepository<TEntity>();
|
||||||
Repository = Orm.GetRepository<TEntity>();
|
|
||||||
|
|
||||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||||
return Repository.InsertAsync(this as TEntity);
|
return Repository.InsertAsync(this as TEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To insert or update data <br />
|
||||||
/// 更新或插入
|
/// 更新或插入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual Task<TEntity> SaveAsync()
|
public virtual Task<TEntity> SaveAsync()
|
||||||
{
|
{
|
||||||
UpdateTime = DateTime.Now;
|
UpdateTime = DateTime.Now;
|
||||||
if (Repository is null)
|
Repository ??= Orm.GetRepository<TEntity>();
|
||||||
Repository = Orm.GetRepository<TEntity>();
|
|
||||||
|
|
||||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||||
return Repository.InsertOrUpdateAsync(this as TEntity);
|
return Repository.InsertOrUpdateAsync(this as TEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// To completely save the navigation properties of the entity in the form of sub-tables. <br />
|
||||||
/// 【完整】保存导航属性,子表
|
/// 【完整】保存导航属性,子表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="navigatePropertyName">导航属性名</param>
|
/// <param name="navigatePropertyName">Navigation property name</param>
|
||||||
public virtual Task SaveManyAsync(string navigatePropertyName)
|
public virtual Task SaveManyAsync(string navigatePropertyName)
|
||||||
{
|
{
|
||||||
if (Repository is null)
|
Repository ??= Orm.GetRepository<TEntity>();
|
||||||
Repository = Orm.GetRepository<TEntity>();
|
|
||||||
|
|
||||||
Repository.UnitOfWork = _resolveUow?.Invoke();
|
Repository.UnitOfWork = _resolveUow?.Invoke();
|
||||||
return Repository.SaveManyAsync(this as TEntity, navigatePropertyName);
|
return Repository.SaveManyAsync(this as TEntity, navigatePropertyName);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user