View Source
Class EntityRepositoryBase<TId, TEntity>
Provides a base class to all IEntity based repositories.
Inheritance
System.Object
Assembly: Umbraco.Infrastructure.dll
Syntax
public abstract class EntityRepositoryBase<TId, TEntity> : RepositoryBase, IReadWriteQueryRepository<TId, TEntity>, IReadRepository<TId, TEntity>, IWriteRepository<TEntity>, IQueryRepository<TEntity>, IRepository where TEntity : class, IEntity
Type Parameters
Name |
Description |
TId |
The type of the entity's unique identifier.
|
TEntity |
The type of the entity managed by this repository.
|
Constructors
View Source
EntityRepositoryBase(IScopeAccessor, AppCaches, ILogger<EntityRepositoryBase<TId, TEntity>>)
Declaration
protected EntityRepositoryBase(IScopeAccessor scopeAccessor, AppCaches appCaches, ILogger<EntityRepositoryBase<TId, TEntity>> logger)
Parameters
Properties
View Source
CachePolicy
Gets the repository cache policy
Declaration
protected IRepositoryCachePolicy<TEntity, TId> CachePolicy { get; }
Property Value
View Source
DefaultOptions
Declaration
protected virtual RepositoryCachePolicyOptions DefaultOptions { get; }
Property Value
View Source
GlobalIsolatedCache
Gets the isolated cache for the TEntity
Declaration
protected IAppPolicyCache GlobalIsolatedCache { get; }
Property Value
View Source
IsolatedCache
Declaration
protected IAppPolicyCache IsolatedCache { get; }
Property Value
View Source
Logger
Declaration
protected ILogger<EntityRepositoryBase<TId, TEntity>> Logger { get; }
Property Value
Methods
View Source
Count(IQuery<TEntity>)
Returns an integer with the count of entities found with the passed in query
Declaration
public int Count(IQuery<TEntity> query)
Parameters
Type |
Name |
Description |
IQuery<TEntity> |
query |
|
Returns
Type |
Description |
System.Int32 |
|
View Source
CreateCachePolicy()
Create the repository cache policy
Declaration
protected virtual IRepositoryCachePolicy<TEntity, TId> CreateCachePolicy()
Returns
View Source
Delete(TEntity)
Deletes the passed in entity
Declaration
public virtual void Delete(TEntity entity)
Parameters
Type |
Name |
Description |
TEntity |
entity |
|
View Source
Exists(TId)
Returns a boolean indicating whether an entity with the passed Id exists
Declaration
public bool Exists(TId id)
Parameters
Type |
Name |
Description |
TId |
id |
|
Returns
Type |
Description |
System.Boolean |
|
View Source
Get(TId)
Gets an entity by the passed in Id utilizing the repository's cache policy
Declaration
public TEntity Get(TId id)
Parameters
Type |
Name |
Description |
TId |
id |
|
Returns
View Source
Get(IQuery<TEntity>)
Gets a list of entities by the passed in query
Declaration
public IEnumerable<TEntity> Get(IQuery<TEntity> query)
Parameters
Type |
Name |
Description |
IQuery<TEntity> |
query |
|
Returns
Type |
Description |
IEnumerable<TEntity> |
|
View Source
GetBaseQuery(Boolean)
Declaration
protected abstract Sql<ISqlContext> GetBaseQuery(bool isCount)
Parameters
Type |
Name |
Description |
System.Boolean |
isCount |
|
Returns
View Source
GetBaseWhereClause()
Declaration
protected abstract string GetBaseWhereClause()
Returns
Type |
Description |
System.String |
|
View Source
GetDeleteClauses()
Declaration
protected abstract IEnumerable<string> GetDeleteClauses()
Returns
Type |
Description |
IEnumerable<System.String> |
|
View Source
GetEntityId(TEntity)
Get the entity id for the TEntity
.
Declaration
protected virtual TId GetEntityId(TEntity entity)
Parameters
Type |
Name |
Description |
TEntity |
entity |
|
Returns
View Source
GetMany(TId[])
Gets all entities of type TEntity or a list according to the passed in Ids
Declaration
public IEnumerable<TEntity> GetMany(params TId[] ids)
Parameters
Type |
Name |
Description |
TId[] |
ids |
|
Returns
Type |
Description |
IEnumerable<TEntity> |
|
View Source
Declaration
protected virtual int PerformCount(IQuery<TEntity> query)
Parameters
Type |
Name |
Description |
IQuery<TEntity> |
query |
|
Returns
Type |
Description |
System.Int32 |
|
View Source
Declaration
protected virtual bool PerformExists(TId id)
Parameters
Type |
Name |
Description |
TId |
id |
|
Returns
Type |
Description |
System.Boolean |
|
View Source
Declaration
protected abstract TEntity PerformGet(TId id)
Parameters
Type |
Name |
Description |
TId |
id |
|
Returns
View Source
Declaration
protected abstract IEnumerable<TEntity> PerformGetAll(params TId[] ids)
Parameters
Type |
Name |
Description |
TId[] |
ids |
|
Returns
Type |
Description |
IEnumerable<TEntity> |
|
View Source
Declaration
protected abstract IEnumerable<TEntity> PerformGetByQuery(IQuery<TEntity> query)
Parameters
Type |
Name |
Description |
IQuery<TEntity> |
query |
|
Returns
Type |
Description |
IEnumerable<TEntity> |
|
View Source
PersistDeletedItem(TEntity)
Declaration
protected virtual void PersistDeletedItem(TEntity entity)
Parameters
Type |
Name |
Description |
TEntity |
entity |
|
View Source
PersistNewItem(TEntity)
Declaration
protected abstract void PersistNewItem(TEntity item)
Parameters
Type |
Name |
Description |
TEntity |
item |
|
View Source
PersistUpdatedItem(TEntity)
Declaration
protected abstract void PersistUpdatedItem(TEntity item)
Parameters
Type |
Name |
Description |
TEntity |
item |
|
View Source
Save(TEntity)
Adds or Updates an entity of type TEntity
Declaration
public virtual void Save(TEntity entity)
Parameters
Type |
Name |
Description |
TEntity |
entity |
|