Class AbstractKeyCachedRepo<TEntity, K>
IRepo<TEntity> for a small number of (cached) persistent instances with key.
public abstract class AbstractKeyCachedRepo<TEntity, K> : BaseNonQueryRepo<TEntity>, IKeyCachedRepo<TEntity, K>, INonQueryRepo<TEntity>, IKeyLookup<TEntity, K> where TEntity : class, new() where K : notnull
Type Parameters
TEntityK
- Inheritance
-
BaseNonQueryRepo<TEntity>AbstractKeyCachedRepo<TEntity, K>
- Implements
-
IKeyCachedRepo<TEntity, K>INonQueryRepo<TEntity>IKeyLookup<TEntity, K>
- Inherited Members
- Extension Methods
Constructors
AbstractKeyCachedRepo(IDataStore)
Ctor from store.
public AbstractKeyCachedRepo(IDataStore store)
Parameters
storeIDataStore
Fields
MAX_CACHE
Maximum cache size.
public const int MAX_CACHE = 300
Field Value
Properties
AllUntracked
A queryable enumeration of ALL (cached) entities of TEntity in the store.
public IQueryable<TEntity> AllUntracked { get; }
Property Value
- IQueryable<TEntity>
Remarks
Changes to returned entities are NOT beeing tracked.
getKeyExpression
Expression that obtains the key value of an entity.
protected abstract Expression<Func<TEntity, K>> getKeyExpression { get; }
Property Value
- Expression<Func<TEntity, K>>
Methods
GetByKey(K, bool)
Return T with key (and optional mustExist flag).
public TEntity? GetByKey(K key, bool mustExist = false)
Parameters
keyKmustExistbool
Returns
- TEntity
Exceptions
- DataEntityNotFoundException<T>
mustExistis true and no entity with givenkey
InsertOrUpdate(TEntity)
(Mark) ent as updated or inserted.
public TEntity InsertOrUpdate(TEntity ent)
Parameters
entTEntity
Returns
- TEntity
supplementalQuery(IQueryable<TEntity>)
Override implementations should return a supplemented query to add e.g. LoadRelated(...) clauses.
protected virtual IQueryable<TEntity> supplementalQuery(IQueryable<TEntity> query)
Parameters
queryIQueryable<TEntity>
Returns
- IQueryable<TEntity>