@@ -43,18 +43,38 @@ public interface IBaseRepository : IDisposable
4343 public interface IBaseRepository < TEntity > : IBaseRepository
4444 where TEntity : class
4545 {
46+ /// <summary>
47+ /// 查询数据
48+ /// </summary>
4649 ISelect < TEntity > Select { get ; }
4750
51+ /// <summary>
52+ /// 筛选数据
53+ /// </summary>
54+ /// <param name="exp">Lambda 筛选表达式</param>
55+ /// <returns>筛选后的查询对象</returns>
4856 ISelect < TEntity > Where ( Expression < Func < TEntity , bool > > exp ) ;
4957 ISelect < TEntity > WhereIf ( bool condition , Expression < Func < TEntity , bool > > exp ) ;
5058
59+ /// <summary>
60+ /// 插入实体
61+ /// </summary>
62+ /// <param name="entity">需要插入的实体对象</param>
63+ /// <returns>插入后的实体对象</returns>
5164 TEntity Insert ( TEntity entity ) ;
52- List < TEntity > Insert ( IEnumerable < TEntity > entitys ) ;
65+
66+ /// <summary>
67+ /// 批量插入实体
68+ /// </summary>
69+ /// <param name="entities">需要插入的实体对象集合</param>
70+ /// <returns>插入后的实体对象集合</returns>
71+ List < TEntity > Insert ( IEnumerable < TEntity > entities ) ;
5372
5473 /// <summary>
5574 /// 清空状态数据
5675 /// </summary>
5776 void FlushState ( ) ;
77+
5878 /// <summary>
5979 /// 附加实体,可用于不查询就更新或删除
6080 /// </summary>
@@ -73,15 +93,51 @@ public interface IBaseRepository<TEntity> : IBaseRepository
7393 /// <returns>key: 属性名, value: [旧值, 新值]</returns>
7494 Dictionary < string , object [ ] > CompareState ( TEntity newdata ) ;
7595
96+ /// <summary>
97+ /// 更新实体
98+ /// </summary>
99+ /// <param name="entity">需要更新的实体对象</param>
100+ /// <returns>返回受影响的行数</returns>
76101 int Update ( TEntity entity ) ;
77- int Update ( IEnumerable < TEntity > entitys ) ;
102+
103+ /// <summary>
104+ /// 更新实体集合
105+ /// </summary>
106+ /// <param name="entities">需要更新的实体对象集合</param>
107+ /// <returns>返回受影响的行数</returns>
108+ int Update ( IEnumerable < TEntity > entities ) ;
78109
110+ /// <summary>
111+ /// 更新实体,不存在则插入
112+ /// </summary>
113+ /// <param name="entity">需要插入或更新的实体对象</param>
114+ /// <returns>受影响的行数</returns>
79115 TEntity InsertOrUpdate ( TEntity entity ) ;
80116
117+ /// <summary>
118+ /// DIY 方式更新
119+ /// </summary>
81120 IUpdate < TEntity > UpdateDiy { get ; }
82121
122+ /// <summary>
123+ /// 根据主键删除实体
124+ /// </summary>
125+ /// <param name="entity">需要删除的实体</param>
126+ /// <returns>受影响的行数</returns>
83127 int Delete ( TEntity entity ) ;
84- int Delete ( IEnumerable < TEntity > entitys ) ;
128+
129+ /// <summary>
130+ /// 批量删除实体,一样是根据主键删除
131+ /// </summary>
132+ /// <param name="entities">需要删除的实体对象集合</param>
133+ /// <returns>受影响的行数</returns>
134+ int Delete ( IEnumerable < TEntity > entities ) ;
135+
136+ /// <summary>
137+ /// 根据 Lambda 表达式删除实体
138+ /// </summary>
139+ /// <param name="predicate">Lambda 表达式,用于筛选需要删除的实体</param>
140+ /// <returns>受影响的行数</returns>
85141 int Delete ( Expression < Func < TEntity , bool > > predicate ) ;
86142 /// <summary>
87143 /// 根据设置的 OneToOne/OneToMany/ManyToMany 导航属性,级联查询所有的数据库记录,删除并返回它们
@@ -121,15 +177,15 @@ public interface IBaseRepository<TEntity> : IBaseRepository
121177#if net40
122178#else
123179 Task < TEntity > InsertAsync ( TEntity entity , CancellationToken cancellationToken = default ) ;
124- Task < List < TEntity > > InsertAsync ( IEnumerable < TEntity > entitys , CancellationToken cancellationToken = default ) ;
180+ Task < List < TEntity > > InsertAsync ( IEnumerable < TEntity > entities , CancellationToken cancellationToken = default ) ;
125181
126182 Task < int > UpdateAsync ( TEntity entity , CancellationToken cancellationToken = default ) ;
127- Task < int > UpdateAsync ( IEnumerable < TEntity > entitys , CancellationToken cancellationToken = default ) ;
183+ Task < int > UpdateAsync ( IEnumerable < TEntity > entities , CancellationToken cancellationToken = default ) ;
128184 Task < TEntity > InsertOrUpdateAsync ( TEntity entity , CancellationToken cancellationToken = default ) ;
129185 Task SaveManyAsync ( TEntity entity , string propertyName , CancellationToken cancellationToken = default ) ;
130186
131187 Task < int > DeleteAsync ( TEntity entity , CancellationToken cancellationToken = default ) ;
132- Task < int > DeleteAsync ( IEnumerable < TEntity > entitys , CancellationToken cancellationToken = default ) ;
188+ Task < int > DeleteAsync ( IEnumerable < TEntity > entities , CancellationToken cancellationToken = default ) ;
133189 Task < int > DeleteAsync ( Expression < Func < TEntity , bool > > predicate , CancellationToken cancellationToken = default ) ;
134190 Task < List < object > > DeleteCascadeByDatabaseAsync ( Expression < Func < TEntity , bool > > predicate , CancellationToken cancellationToken = default ) ;
135191#endif
0 commit comments