Table of Contents

Interface IDataStore

Namespace
Tlabs.Data
Assembly
Tlabs.Data.dll

Interface of an abstract data persistence store.

public interface IDataStore
Extension Methods

Properties

AutoCommit

True if tracked changes are (auto) committed on store dispose.

bool AutoCommit { get; set; }

Property Value

bool

Methods

Attach<E>(E)

Attach given ent as unchanged (but tracked).

E Attach<E>(E ent) where E : class

Parameters

ent E

Returns

E

Type Parameters

E

CommitChanges()

Commit all tracked (detected) changes to the undrlying persistence store.

void CommitChanges()

Delete<E>(IEnumerable<E>)

Mark IEnumerable<T> of entities as deleted for removing from the store.

void Delete<E>(IEnumerable<E> entities) where E : class

Parameters

entities IEnumerable<E>

Type Parameters

E

Delete<E>(E)

Mark given ent as deleted for removing from the store.

void Delete<E>(E ent) where E : class

Parameters

ent E

Type Parameters

E

EnsureStore(IEnumerable<IDataSeed>?)

Take actions to make sure the underlying store exists and optional plants all provided seeds.

void EnsureStore(IEnumerable<IDataSeed>? seeds = null)

Parameters

seeds IEnumerable<IDataSeed>

Remarks

Should create the entire store, if not present.

Evict<E>(E)

Evict given ent from beeing tracked by the repository.

void Evict<E>(E ent) where E : class

Parameters

ent E

Type Parameters

E

GetIdentifier<E>(E)

Get the data store identifier value(s) of the given ent.

object GetIdentifier<E>(E ent) where E : class

Parameters

ent E

Returns

object

Type Parameters

E

Get<E>(params object[])

Get a persistent entity instance from the data store.

E Get<E>(params object[] ids) where E : class

Parameters

ids object[]

Returns

E

Type Parameters

E

Insert<E>(IEnumerable<E>)

Add an IEnumerable<T> of entities for inserting to the store.

IEnumerable<E> Insert<E>(IEnumerable<E> entities) where E : class

Parameters

entities IEnumerable<E>

Returns

IEnumerable<E>

Type Parameters

E

Insert<E>(E)

Add ent for inserting to the store.

E Insert<E>(E ent) where E : class

Parameters

ent E

Returns

E

Type Parameters

E

LoadExplicit<E, P>(E, Expression<Func<E, IEnumerable<P>>>)

Explicitly load collection prop from ent (if not already loaded).

E LoadExplicit<E, P>(E ent, Expression<Func<E, IEnumerable<P>>> prop) where E : class where P : class

Parameters

ent E
prop Expression<Func<E, IEnumerable<P>>>

Returns

E

Type Parameters

E
P

LoadExplicit<E, P>(E, Expression<Func<E, P?>>)

Explicitly load referenced prop from ent (if not already loaded).

E LoadExplicit<E, P>(E ent, Expression<Func<E, P?>> prop) where E : class where P : class

Parameters

ent E
prop Expression<Func<E, P>>

Returns

E

Type Parameters

E
P

LoadRelated<E>(IQueryable<E>, string)

Load related data associated with the given navigationPropertyPath with the entities selected by the query.

IQueryable<E> LoadRelated<E>(IQueryable<E> query, string navigationPropertyPath) where E : class

Parameters

query IQueryable<E>
navigationPropertyPath string

Returns

IQueryable<E>

Type Parameters

E

Remarks

navigationPropertyPath is a '.' separated path of navigation property names (all) to be included.

LoadRelated<E, P>(IQueryable<E>, Expression<Func<E, P>>)

Load related data associated with the given navProperty with the entities selected by the query.

IEagerLoadedQueryable<E, P> LoadRelated<E, P>(IQueryable<E> query, Expression<Func<E, P>> navProperty) where E : class

Parameters

query IQueryable<E>
navProperty Expression<Func<E, P>>

Returns

IEagerLoadedQueryable<E, P>

Type Parameters

E
P

Remarks

This method can be chained to eagerly load multiple navigation properties.

Merge<E>(E)

Merge given ent with any persistent version.

E Merge<E>(E ent) where E : class, new()

Parameters

ent E

Returns

E

Type Parameters

E

Remarks

A merge is especially usefull when persisting data updated from an input form that typically does not manage any navigation properties (i.e. references to other entities) and thus will leave such properties with their default value (null).

  • if the given entity is not persistent yet it gets inserted, else only properties with non-null values are set on the persistent entity.
  • Any property changed by the merge operation marks the entity as modified for updating with the store.

Query<E>()

Return a queryable enumeration of ALL entities of E in the store.

IQueryable<E> Query<E>() where E : class

Returns

IQueryable<E>

Type Parameters

E

Remarks

Any changes to returned entities are beeing tracked (for potential commit with the underlying store).

ResetAll()

Reset all tracked entities to 'untracked'.

void ResetAll()

ResetChanges()

Reset the change state of all tracked entities to 'unchanged'.

void ResetChanges()

ThenLoadRelated<E, Prev, Prop>(IEagerLoadedQueryable<E, IEnumerable<Prev>>, Expression<Func<Prev, Prop>>)

Load additional related data associated with the given navProperty based on a related type that was just loaded.

IEagerLoadedQueryable<E, Prop> ThenLoadRelated<E, Prev, Prop>(IEagerLoadedQueryable<E, IEnumerable<Prev>> query, Expression<Func<Prev, Prop>> navProperty) where E : class

Parameters

query IEagerLoadedQueryable<E, IEnumerable<Prev>>
navProperty Expression<Func<Prev, Prop>>

Returns

IEagerLoadedQueryable<E, Prop>

Type Parameters

E
Prev
Prop

ThenLoadRelated<E, Prev, Prop>(IEagerLoadedQueryable<E, Prev>, Expression<Func<Prev, Prop>>)

Load additional related data associated with the given navProperty based on a related type that was just loaded.

IEagerLoadedQueryable<E, Prop> ThenLoadRelated<E, Prev, Prop>(IEagerLoadedQueryable<E, Prev> query, Expression<Func<Prev, Prop>> navProperty) where E : class

Parameters

query IEagerLoadedQueryable<E, Prev>
navProperty Expression<Func<Prev, Prop>>

Returns

IEagerLoadedQueryable<E, Prop>

Type Parameters

E
Prev
Prop

UntrackedQuery<E>()

Return a queryable enumeration of ALL entities of E in the store.

IQueryable<E> UntrackedQuery<E>() where E : class

Returns

IQueryable<E>

Type Parameters

E

Remarks

Changes to returned entities are NOT beeing tracked.

Update<E>(IEnumerable<E>)

Track IEnumerable<T> of entities as modified for updating with the store.

IEnumerable<E> Update<E>(IEnumerable<E> entities) where E : class

Parameters

entities IEnumerable<E>

Returns

IEnumerable<E>

Type Parameters

E

Update<E>(E)

Track given ent as modified for updating with the store.

E Update<E>(E ent) where E : class

Parameters

ent E

Returns

E

Type Parameters

E

WithTransaction(Action<IDataTransaction>)

Excecutes operation within a transaction.

void WithTransaction(Action<IDataTransaction> operation)

Parameters

operation Action<IDataTransaction>

Remarks

The operation needs to call Commit() to commit.