Table of Contents

Interface IRepository<TEntity, TPrimaryKey>

Namespace
HeBianGu.Base.WpfBase
Assembly
HeBianGu.Base.WpfBase.dll

定义泛型仓储接口

public interface IRepository<TEntity, TPrimaryKey> : IRepository where TEntity : EntityBase<TPrimaryKey>

Type Parameters

TEntity

实体类型

TPrimaryKey

主键类型

Extension Methods

Methods

Clear(bool)

删除实体

int Clear(bool autoSave = true)

Parameters

autoSave bool

是否立即执行保存

Returns

int

ClearAsync(bool)

删除实体

Task<int> ClearAsync(bool autoSave = true)

Parameters

autoSave bool

是否立即执行保存

Returns

Task<int>

Delete(TEntity, bool)

删除实体

int Delete(TEntity entity, bool autoSave = true)

Parameters

entity TEntity

要删除的实体

autoSave bool

是否立即执行保存

Returns

int

DeleteAsync(Expression<Func<TEntity, bool>>, bool)

根据条件删除实体

Task<int> DeleteAsync(Expression<Func<TEntity, bool>> where, bool autoSave = true)

Parameters

where Expression<Func<TEntity, bool>>

lambda表达式

autoSave bool

是否自动保存

Returns

Task<int>

DeleteAsync(TEntity, bool)

删除实体

Task<int> DeleteAsync(TEntity entity, bool autoSave = true)

Parameters

entity TEntity

要删除的实体

autoSave bool

是否立即执行保存

Returns

Task<int>

DeleteByID(TPrimaryKey, bool)

删除实体

int DeleteByID(TPrimaryKey id, bool autoSave = true)

Parameters

id TPrimaryKey

实体主键

autoSave bool

是否立即执行保存

Returns

int

DeleteByIDAsync(TPrimaryKey, bool)

删除实体

Task<int> DeleteByIDAsync(TPrimaryKey id, bool autoSave = true)

Parameters

id TPrimaryKey

实体主键

autoSave bool

是否立即执行保存

Returns

Task<int>

FirstOrDefaultAsync(Expression<Func<TEntity, bool>>)

根据lambda表达式条件获取单个实体

Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate)

Parameters

predicate Expression<Func<TEntity, bool>>

lambda表达式条件

Returns

Task<TEntity>

GetByIDAsync(TPrimaryKey)

根据主键获取实体

Task<TEntity> GetByIDAsync(TPrimaryKey id)

Parameters

id TPrimaryKey

实体主键

Returns

Task<TEntity>

GetList()

获取实体集合

List<TEntity> GetList()

Returns

List<TEntity>

GetList(Action<IQueryable<TEntity>>)

List<TEntity> GetList(Action<IQueryable<TEntity>> action)

Parameters

action Action<IQueryable<TEntity>>

Returns

List<TEntity>

GetList(Expression<Func<TEntity, bool>>)

根据lambda表达式条件获取实体集合

List<TEntity> GetList(Expression<Func<TEntity, bool>> predicate)

Parameters

predicate Expression<Func<TEntity, bool>>

lambda表达式条件

Returns

List<TEntity>

GetList(params string[])

获取实体集合

List<TEntity> GetList(params string[] includes)

Parameters

includes string[]

Returns

List<TEntity>

GetListAsync()

获取实体集合

Task<List<TEntity>> GetListAsync()

Returns

Task<List<TEntity>>

GetListAsync(Expression<Func<TEntity, bool>>)

根据lambda表达式条件获取实体集合

Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate)

Parameters

predicate Expression<Func<TEntity, bool>>

lambda表达式条件

Returns

Task<List<TEntity>>

GetListAsync(params string[])

获取实体集合

Task<List<TEntity>> GetListAsync(params string[] includes)

Parameters

includes string[]

Returns

Task<List<TEntity>>

Insert(TEntity, bool)

新增实体

int Insert(TEntity entity, bool autoSave = true)

Parameters

entity TEntity

实体

autoSave bool

是否立即执行保存

Returns

int

InsertAsync(TEntity, bool)

新增实体

Task<int> InsertAsync(TEntity entity, bool autoSave = true)

Parameters

entity TEntity

实体

autoSave bool

是否立即执行保存

Returns

Task<int>

InsertOrUpdateAsync(TEntity, bool)

新增或更新实体

Task<int> InsertOrUpdateAsync(TEntity entity, bool autoSave = true)

Parameters

entity TEntity

实体

autoSave bool

是否立即执行保存

Returns

Task<int>

InsertRangeAsync(params TEntity[])

新增实体

Task<int> InsertRangeAsync(params TEntity[] entity)

Parameters

entity TEntity[]

实体

Returns

Task<int>

LoadPageList(int, int, Expression<Func<TEntity, bool>>, Expression<Func<TEntity, object>>)

分页获取数据

Task<Tuple<List<TEntity>, int>> LoadPageList(int startPage, int pageSizet, Expression<Func<TEntity, bool>> where = null, Expression<Func<TEntity, object>> order = null)

Parameters

startPage int

起始页

pageSizet int
where Expression<Func<TEntity, bool>>

查询条件

order Expression<Func<TEntity, object>>

排序

Returns

Task<Tuple<List<TEntity>, int>>

Save()

保存

int Save()

Returns

int

SaveAsync()

保存

Task<int> SaveAsync()

Returns

Task<int>

Update(TEntity, bool)

更新实体

int Update(TEntity entity, bool autoSave = true)

Parameters

entity TEntity

实体

autoSave bool

是否立即执行保存

Returns

int

UpdateAsync(TEntity, bool)

更新实体

Task<int> UpdateAsync(TEntity entity, bool autoSave = true)

Parameters

entity TEntity

实体

autoSave bool

是否立即执行保存

Returns

Task<int>