Table of Contents

Class AbstractKeyCachedRepo<TEntity, K>

Namespace
Tlabs.Data.Repo.Intern
Assembly
Tlabs.Data.dll

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

TEntity
K
Inheritance
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

store IDataStore

Fields

MAX_CACHE

Maximum cache size.

public const int MAX_CACHE = 300

Field Value

int

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

key K
mustExist bool

Returns

TEntity

Exceptions

DataEntityNotFoundException<T>

mustExist is true and no entity with given key

InsertOrUpdate(TEntity)

(Mark) ent as updated or inserted.

public TEntity InsertOrUpdate(TEntity ent)

Parameters

ent TEntity

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

query IQueryable<TEntity>

Returns

IQueryable<TEntity>