Table of Contents

Class BaseDbRepository<TEntity>

Namespace
NLightning.Infrastructure.Repositories.Database
Assembly
NLightning.Infrastructure.Repositories.dll
public class BaseDbRepository<TEntity> where TEntity : class

Type Parameters

TEntity
Inheritance
BaseDbRepository<TEntity>
Derived
Inherited Members

Constructors

BaseDbRepository(NLightningDbContext)

protected BaseDbRepository(NLightningDbContext context)

Parameters

context NLightningDbContext

Fields

DbSet

protected readonly DbSet<TEntity> DbSet

Field Value

DbSet<TEntity>

Methods

Delete(TEntity)

protected void Delete(TEntity entityToDelete)

Parameters

entityToDelete TEntity

DeleteByIdAsync(object)

protected Task DeleteByIdAsync(object id)

Parameters

id object

Returns

Task

DeleteRange(IEnumerable<TEntity>)

protected void DeleteRange(IEnumerable<TEntity> entitiesToDelete)

Parameters

entitiesToDelete IEnumerable<TEntity>

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

protected void DeleteWhere(Expression<Func<TEntity, bool>> predicate)

Parameters

predicate Expression<Func<TEntity, bool>>

Get(Expression<Func<TEntity, bool>>?, Expression<Func<TEntity, object>>?, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>>?, bool, int, int)

protected IQueryable<TEntity> Get(Expression<Func<TEntity, bool>>? predicate = null, Expression<Func<TEntity, object>>? include = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>>? orderBy = null, bool asNoTracking = true, int perPage = 0, int pageNumber = 1)

Parameters

predicate Expression<Func<TEntity, bool>>
include Expression<Func<TEntity, object>>
orderBy Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>>
asNoTracking bool
perPage int
pageNumber int

Returns

IQueryable<TEntity>

GetByIdAsync(object, bool, Expression<Func<TEntity, object>>?)

protected Task<TEntity?> GetByIdAsync(object id, bool asNoTracking = true, Expression<Func<TEntity, object>>? include = null)

Parameters

id object
asNoTracking bool
include Expression<Func<TEntity, object>>

Returns

Task<TEntity>

Insert(TEntity)

protected void Insert(TEntity entity)

Parameters

entity TEntity

Update(TEntity)

protected void Update(TEntity entityToUpdate)

Parameters

entityToUpdate TEntity