Class Repository<TQueryStrategy, TQueryBuilder, TData>
Provides basic repository methods for operations with an IDataStore<TData>.
Inheritance
Inherited Members
Namespace: Cqrs.Repositories
Assembly: Cqrs.dll
Syntax
public abstract class Repository<TQueryStrategy, TQueryBuilder, TData> : IRepository<TQueryStrategy, TData> where TQueryStrategy : IQueryStrategy where TQueryBuilder : QueryBuilder<TQueryStrategy, TData> where TData : Entity
Type Parameters
Name | Description |
---|---|
TQueryStrategy | The System.Type of IQueryStrategy. |
TQueryBuilder | The System.Type of the QueryBuilder<TQueryStrategy, TData> that will be used to build queries. |
TData | The System.Type of data held in storage. |
Constructors
Repository(Func<IDataStore<TData>>, TQueryBuilder)
Instantiates a new instance of Repository<TQueryStrategy, TQueryBuilder, TData>
Declaration
protected Repository(Func<IDataStore<TData>> createDataStoreFunction, TQueryBuilder queryBuilder)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IDataStore<TData>> | createDataStoreFunction | |
TQueryBuilder | queryBuilder |
Properties
CreateDataStoreFunction
Gets or sets the System.Func<TResult> that is used to create new instances of IDataStore<TData>.
Declaration
protected Func<IDataStore<TData>> CreateDataStoreFunction { get; }
Property Value
Type | Description |
---|---|
System.Func<IDataStore<TData>> |
QueryBuilder
Gets or sets the TQueryBuilder
that will be used to build queries.
Declaration
protected TQueryBuilder QueryBuilder { get; }
Property Value
Type | Description |
---|---|
TQueryBuilder |
TelemetryHelper
Gets or sets the cdmdotnet.Logging.ITelemetryHelper.
Declaration
protected ITelemetryHelper TelemetryHelper { get; set; }
Property Value
Type | Description |
---|---|
cdmdotnet.Logging.ITelemetryHelper |
Methods
Create(TData)
Create the newly provided data
to storage.
Declaration
public virtual void Create(TData data)
Parameters
Type | Name | Description |
---|---|---|
TData | data |
Implements
Create(IEnumerable<TData>)
Create the newly provided data
to storage.
Declaration
public virtual void Create(IEnumerable<TData> data)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TData> | data |
Implements
CreateQueryable(Expression<Func<TData, Boolean>>)
Calls CreateDataStoreFunction passing the predicate
.
Declaration
protected virtual IQueryable<TData> CreateQueryable(Expression<Func<TData, bool>> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TData, System.Boolean>> | predicate | A function defining a filter if required. |
Returns
Type | Description |
---|---|
System.Linq.IQueryable<TData> |
Delete(TData)
Will mark the data
as logically (or soft).
Declaration
public virtual void Delete(TData data)
Parameters
Type | Name | Description |
---|---|---|
TData | data |
Implements
DeleteAll()
Delete all contents (normally by use of a truncate operation) in storage.
Declaration
public virtual void DeleteAll()
Implements
Destroy(TData)
Remove the provided data
from storage.
Declaration
public void Destroy(TData data)
Parameters
Type | Name | Description |
---|---|---|
TData | data |
Implements
Load(Guid, Boolean)
Load the TData
from storage identified by the provided rsn
.
Declaration
public virtual TData Load(Guid rsn, bool throwExceptionOnMissingEntity = true)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | rsn | The identifier if the |
System.Boolean | throwExceptionOnMissingEntity | If true will throw an System.Exception if no data is found in storage. |
Returns
Type | Description |
---|---|
TData |
Implements
Retrieve(ICollectionResultQuery<TQueryStrategy, TData>)
Builds and executes the provided resultQuery
.
Declaration
public virtual ICollectionResultQuery<TQueryStrategy, TData> Retrieve(ICollectionResultQuery<TQueryStrategy, TData> resultQuery)
Parameters
Type | Name | Description |
---|---|---|
ICollectionResultQuery<TQueryStrategy, TData> | resultQuery | The ICollectionResultQuery<TQueryStrategy, TData> to build and execute. |
Returns
Type | Description |
---|---|
ICollectionResultQuery<TQueryStrategy, TData> |
Implements
Retrieve(ISingleResultQuery<TQueryStrategy, TData>, Boolean)
Builds and executes the provided singleResultQuery
.
Declaration
public virtual ISingleResultQuery<TQueryStrategy, TData> Retrieve(ISingleResultQuery<TQueryStrategy, TData> singleResultQuery, bool throwExceptionWhenNoQueryResults = true)
Parameters
Type | Name | Description |
---|---|---|
ISingleResultQuery<TQueryStrategy, TData> | singleResultQuery | The ISingleResultQuery<TQueryStrategy, TData> to build and execute. |
System.Boolean | throwExceptionWhenNoQueryResults | If true will throw an System.Exception if no data is found in storage. |
Returns
Type | Description |
---|---|
ISingleResultQuery<TQueryStrategy, TData> |
Implements
Update(TData)
Update the provided data
in storage.
Declaration
public virtual void Update(TData data)
Parameters
Type | Name | Description |
---|---|---|
TData | data |