
EntityFrameworkRepository<TEntity, TContext>
Performs data access operations against an Entity Framework entity type using a single transaction.
Inherited Members
Namespace: RapidField.SolidInstruments.DataAccess.EntityFramework
Assembly: RapidField.SolidInstruments.DataAccess.EntityFramework.dll
Syntax (C#)
public class EntityFrameworkRepository<TEntity, TContext> : DataAccessRepository<TEntity>, IDataAccessRepository<TEntity>, IDataAccessRepository, IDisposable where TEntity : class where TContext : DbContext
Type Parameters
Name | Description |
---|---|
TEntity | The type of the entity. |
TContext | The type of the database session for the repository. |
Constructors
EntityFrameworkRepository(TContext)
Initializes a new instance of the EntityFrameworkRepository<TEntity, TContext> class.
Declaration (C#)
public EntityFrameworkRepository(TContext context)
Parameters
Type | Name | Description |
---|---|---|
TContext | context | The database session for the repository. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Methods
Add(TEntity, ConcurrencyControlToken)
Adds the specified entity to the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override void Add(TEntity entity, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | The entity to add. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Overrides
AddRange(IEnumerable<TEntity>, ConcurrencyControlToken)
Adds the specified entities to the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override void AddRange(IEnumerable<TEntity> entities, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | The entities to add. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Overrides
All(ConcurrencyControlToken)
Returns all entities from the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override IQueryable<TEntity> All(ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Returns
Type | Description |
---|---|
IQueryable<TEntity> | All entities within the current EntityFrameworkRepository<TEntity, TContext>. |
Overrides
AnyWhere(Expression<Func<TEntity, Boolean>>, ConcurrencyControlToken)
Determines whether or not any entities matching the specified predicate exist in the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override bool AnyWhere(Expression<Func<TEntity, bool>> predicate, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TEntity, Boolean>> | predicate | An expression to test each entity for a condition. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Returns
Type | Description |
---|---|
Boolean | true if any entities matching the specified predicate exist in the current EntityFrameworkRepository<TEntity, TContext>, otherwise false. |
Overrides
Contains(TEntity, ConcurrencyControlToken)
Determines whether or not the specified entity exists in the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override bool Contains(TEntity entity, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | The entity to evaluate. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Returns
Type | Description |
---|---|
Boolean | true if the specified entity exists in the current EntityFrameworkRepository<TEntity, TContext>, otherwise false. |
Overrides
Count(ConcurrencyControlToken)
Returns the number of entities in the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override long Count(ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Returns
Type | Description |
---|---|
Int64 | The number of entities in the current EntityFrameworkRepository<TEntity, TContext>. |
Overrides
CountWhere(Expression<Func<TEntity, Boolean>>, ConcurrencyControlToken)
Returns the number of entities matching the specified predicate in the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override long CountWhere(Expression<Func<TEntity, bool>> predicate, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TEntity, Boolean>> | predicate | An expression to test each entity for a condition. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Returns
Type | Description |
---|---|
Int64 | The number of entities matching the specified predicate in the current EntityFrameworkRepository<TEntity, TContext>. |
Overrides
Dispose(Boolean)
Releases all resources consumed by the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | A value indicating whether or not managed resources should be released. |
Overrides
FindWhere(Expression<Func<TEntity, Boolean>>, ConcurrencyControlToken)
Returns all entities matching the specified predicate from the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override IQueryable<TEntity> FindWhere(Expression<Func<TEntity, bool>> predicate, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TEntity, Boolean>> | predicate | An expression to test each entity for a condition. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Returns
Type | Description |
---|---|
IQueryable<TEntity> | All entities matching the specified predicate within the current EntityFrameworkRepository<TEntity, TContext>. |
Overrides
Remove(TEntity, ConcurrencyControlToken)
Removes the specified entity from the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override void Remove(TEntity entity, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | The entity to remove. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Overrides
RemoveRange(IEnumerable<TEntity>, ConcurrencyControlToken)
Removes the specified entities from the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override void RemoveRange(IEnumerable<TEntity> entities, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | The entities to remove. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Overrides
Update(TEntity, ConcurrencyControlToken)
Updates the specified entity in the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override void Update(TEntity entity, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | The entity to update. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |
Overrides
UpdateRange(IEnumerable<TEntity>, ConcurrencyControlToken)
Updates the specified entities in the current EntityFrameworkRepository<TEntity, TContext>.
Declaration (C#)
protected override void UpdateRange(IEnumerable<TEntity> entities, ConcurrencyControlToken controlToken)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TEntity> | entities | The entities to update. |
ConcurrencyControlToken | controlToken | A token that represents and manages contextual thread safety. |