Class AbstractKeyCachedRepo<TEntity, TModel, K>
IRepo<TEntity> for a small number of (cached) persistent instances with key.
public abstract class AbstractKeyCachedRepo<TEntity, TModel, K> : BaseNonQueryRepo<TEntity>, IKeyCachedRepo<TEntity, TModel, K>, INonQueryRepo<TEntity>, IKeyLookup<TModel, K> where TEntity : class, new() where TModel : class, new() where K : notnull
Type Parameters
TEntityTModelK
- Inheritance
-
BaseNonQueryRepo<TEntity>AbstractKeyCachedRepo<TEntity, TModel, K>
- Implements
-
IKeyCachedRepo<TEntity, TModel, K>INonQueryRepo<TEntity>IKeyLookup<TModel, 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 TModel in the store.
public IQueryable<TModel> AllUntracked { get; }
Property Value
- IQueryable<TModel>
getKeyExpression
Expression that obtains the key value of a a model object.
protected abstract Expression<Func<TModel, K>> getKeyExpression { get; }
Property Value
- Expression<Func<TModel, K>>
Methods
GetByKey(K, bool)
Return T with key (and optional mustExist flag).
public TModel? GetByKey(K key, bool mustExist = false)
Parameters
keyKmustExistbool
Returns
- TModel
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
selectQuery(IQueryable<TEntity>)
Override implementations must return a selection query to return a TModel.
protected abstract IQueryable<TModel> selectQuery(IQueryable<TEntity> query)
Parameters
queryIQueryable<TEntity>
Returns
- IQueryable<TModel>