仓储层(Repository)
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[ASP.NET Core Web]]
&color(red){※前提条件:本文基于 .NET Core 2.0 创作};
#contents
* 概要 [#wb70db3a]
Repository(仓储)是DDD(领域驱动设计)中的经典思想,可以归纳...
* 基类仓储接口 [#k852a3b0]
基类接口,声明一些所有仓储层接口都拥有的公共功能
#codeprettify{{
/// <summary>
/// 基类仓储接口
/// </summary>
/// <typeparam name="TEntity">Model类型</typeparam>
public interface IBaseRepository<TEntity> where TEntity: ...
{
Task<TEntity> QueryById(object objId);
Task<TEntity> QueryById(object objId, bool blnUseCach...
Task<List<TEntity>> QueryByIDs(object[] lstIds);
Task<int> Add(TEntity model);
Task<int> Add(List<TEntity> listEntity);
Task<bool> DeleteById(object id);
Task<bool> Delete(TEntity model);
Task<bool> DeleteByIds(object[] ids);
Task<bool> Update(TEntity model);
Task<bool> Update(TEntity entity, string strWhere);
Task<bool> Update(object operateAnonymousObjects);
Task<bool> Update(TEntity entity, List<string> lstCol...
Task<List<TEntity>> Query();
Task<List<TEntity>> Query(string strWhere);
Task<List<TEntity>> Query(Expression<Func<TEntity, bo...
Task<List<TEntity>> Query(Expression<Func<TEntity, bo...
Task<List<TEntity>> Query(string strWhere, string str...
Task<List<TEntity>> Query(Expression<Func<TEntity, bo...
Task<List<TEntity>> Query(string strWhere, int intTop...
Task<List<TEntity>> QuerySql(string strSql, SugarPara...
Task<DataTable> QueryTable(string strSql, SugarParame...
Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression, ...
Task<List<TEntity>> Query(string strWhere, int intPag...
Task<PageModel<TEntity>> QueryPage(Expression<Func<TE...
Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpress...
Expression<Func<T, T2, T3, TResult>> selectExpres...
Expression<Func<T, T2, T3, bool>> whereLambda = n...
}
}}
* 构建接口 [#l6dd1417]
根据之前建立的Model类,继承这个基类接口来构建接口(以UserR...
#codeprettify{{
/// <summary>
/// 继承基类接口创建的接口,若有额外方法可以在此处扩展
/// </summary>
public interface IUserRoleRepository : IBaseRepository<Us...
{
}
}}
考虑到事务控制的需要,在仓储接口层新增文件夹UnitOfWork,实...
#codeprettify{{
public interface IUnitOfWork
{
SqlSugarClient GetDbClient();
void BeginTran();
void CommitTran();
void RollbackTran();
}
}}
#hr();
コメント:
#comment_kcaptcha
終了行:
[[ASP.NET Core Web]]
&color(red){※前提条件:本文基于 .NET Core 2.0 创作};
#contents
* 概要 [#wb70db3a]
Repository(仓储)是DDD(领域驱动设计)中的经典思想,可以归纳...
* 基类仓储接口 [#k852a3b0]
基类接口,声明一些所有仓储层接口都拥有的公共功能
#codeprettify{{
/// <summary>
/// 基类仓储接口
/// </summary>
/// <typeparam name="TEntity">Model类型</typeparam>
public interface IBaseRepository<TEntity> where TEntity: ...
{
Task<TEntity> QueryById(object objId);
Task<TEntity> QueryById(object objId, bool blnUseCach...
Task<List<TEntity>> QueryByIDs(object[] lstIds);
Task<int> Add(TEntity model);
Task<int> Add(List<TEntity> listEntity);
Task<bool> DeleteById(object id);
Task<bool> Delete(TEntity model);
Task<bool> DeleteByIds(object[] ids);
Task<bool> Update(TEntity model);
Task<bool> Update(TEntity entity, string strWhere);
Task<bool> Update(object operateAnonymousObjects);
Task<bool> Update(TEntity entity, List<string> lstCol...
Task<List<TEntity>> Query();
Task<List<TEntity>> Query(string strWhere);
Task<List<TEntity>> Query(Expression<Func<TEntity, bo...
Task<List<TEntity>> Query(Expression<Func<TEntity, bo...
Task<List<TEntity>> Query(string strWhere, string str...
Task<List<TEntity>> Query(Expression<Func<TEntity, bo...
Task<List<TEntity>> Query(string strWhere, int intTop...
Task<List<TEntity>> QuerySql(string strSql, SugarPara...
Task<DataTable> QueryTable(string strSql, SugarParame...
Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression, ...
Task<List<TEntity>> Query(string strWhere, int intPag...
Task<PageModel<TEntity>> QueryPage(Expression<Func<TE...
Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpress...
Expression<Func<T, T2, T3, TResult>> selectExpres...
Expression<Func<T, T2, T3, bool>> whereLambda = n...
}
}}
* 构建接口 [#l6dd1417]
根据之前建立的Model类,继承这个基类接口来构建接口(以UserR...
#codeprettify{{
/// <summary>
/// 继承基类接口创建的接口,若有额外方法可以在此处扩展
/// </summary>
public interface IUserRoleRepository : IBaseRepository<Us...
{
}
}}
考虑到事务控制的需要,在仓储接口层新增文件夹UnitOfWork,实...
#codeprettify{{
public interface IUnitOfWork
{
SqlSugarClient GetDbClient();
void BeginTran();
void CommitTran();
void RollbackTran();
}
}}
#hr();
コメント:
#comment_kcaptcha
ページ名: