GenericRepository
Namespace: Babel.Data Assembly: Babel.Data.dll
A generic repository.
Type Parameters
Name | Description |
---|---|
| Type of the entity. |
Inheritance
object ← GenericRepository<TEntity>
Implements
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
GenericRepository(BabelDbContext)
Initializes a new instance of the GenericRepository class.
Parameters
Name | Description |
---|---|
The database context. |
Properties
Context
Gets the Babel database context.
Property Value
DbSet
Gets the set the database belongs to.
Property Value
DbSet<TEntity>
Methods
CountAsync(Expression<Func<TEntity, bool>>, CancellationToken)
Asynchronously returns the number of elements in the repository.
Parameters
Name | Description |
---|---|
(Optional) Specifies the filter. | |
(Optional) A token that allows processing to be cancelled. |
Returns
Name | Description |
---|---|
An asynchronous result that yields the number of elements in the repository. |
CountAsync(string, CancellationToken)
Asynchronously returns the number of elements in the repository.
Parameters
Name | Description |
---|---|
Specifies the string filter. | |
(Optional) A token that allows processing to be cancelled. |
Returns
Name | Description |
---|---|
An asynchronous result that yields the number of elements in the repository. |
Delete(params object[])
Deletes an entity with the given primary key values. Begins tracking the given entity in the Detached state such that it will be deleted in the database when SaveChanges() is called.
Parameters
Name | Description |
---|---|
The values of the primary key for the entity to be found. |
Delete(TEntity)
Deletes the given entity from the repository. Begins tracking the given entity in the Detached state such that it will be deleted in the database when SaveChanges() is called.
Parameters
Name | Description |
---|---|
| The entity to delete. |
Get(Expression<Func<TEntity, bool>>, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>>, string, string, int?, int?)
Gets a list of entities from this repository.
Parameters
Name | Description |
---|---|
(Optional) Specifies the filter expression. | |
(Optional) Order by expression. | |
(Optional) A comma separated list of column names to retrieve. | |
(Optional) A comma separated list of nested entity names to retrieve. | |
(Optional) The number of records to skip before the first record found. | |
(Optional) The number of records to take after the first record found. |
Returns
Name | Description |
---|---|
A list of entities. |
GetAsync(Expression<Func<TEntity, bool>>, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>>, string, string, int?, int?, CancellationToken)
Asynchronously gets a list of entities from this repository.
Parameters
Name | Description |
---|---|
(Optional) Specifies the filter expression. | |
(Optional) Order by expression. | |
(Optional) A comma separated list of column names to retrieve. | |
(Optional) A comma separated list of nested entity names to retrieve. | |
(Optional) The number of records to skip before the first record found. | |
(Optional) The number of records to take after the first record found. | |
(Optional) A token that allows processing to be cancelled. |
Returns
Name | Description |
---|---|
A task that represents the asynchronous get operation. |
GetById(params object[])
Gets an entity with the given primary key values. If an entity with the given primary key values exists in the context, then it is returned immediately without making a request to the store. Otherwise, a request is made to the store for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found in the context or the store, then null is returned.
Parameters
Name | Description |
---|---|
The values of the primary key for the entity to be found. |
Returns
GetByIdAsync(params object[])
Asynchronously gets an entity with the given primary key values. If an entity with the given primary key values exists in the context, then it is returned immediately without making a request to the store. Otherwise, a request is made to the store for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found in the context or the store, then null is returned.
Parameters
Name | Description |
---|---|
The values of the primary key for the entity to be found. |
Returns
Name | Description |
---|---|
A task that represents the asynchronous get operation. The task result contains the entity found, or null. |
GetByIdAsync(object[], CancellationToken)
Asynchronously gets an entity with the given primary key values. If an entity with the given primary key values exists in the context, then it is returned immediately without making a request to the store. Otherwise, a request is made to the store for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found in the context or the store, then null is returned.
Parameters
Name | Description |
---|---|
The values of the primary key for the entity to be found. | |
(Optional) A token that allows processing to be cancelled. |
Returns
Name | Description |
---|---|
A task that represents the asynchronous get operation. The task result contains the entity found, or null. |
Insert(TEntity)
Inserts the given entity in the repository. Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called
Parameters
Name | Description |
---|---|
| The entity to be inserted. |
InsertAsync(TEntity, CancellationToken)
Asynchronously inserts the given entity in the repository. Begins tracking the given entity, and any other reachable entities that are not already being tracked, in the Added state such that they will be inserted into the database when SaveChanges() is called
Parameters
Name | Description |
---|---|
| The entity. |
(Optional) A token that allows processing to be cancelled. |
Returns
Name | Description |
---|---|
A task that represents the asynchronous Insert operation. |
QueryAsync(string, string, string, string, int?, int?, CancellationToken)
Asynchronously query a list of entities from this repository.
Parameters
Name | Description |
---|---|
(Optional) Specifies a select expression. | |
(Optional) Specifies the filter expression. | |
(Optional) Order by expression. | |
(Optional) A comma separated list of nested entity names to retrieve. | |
(Optional) The number of records to skip before the first record found. | |
(Optional) The number of records to take after the first record found. | |
(Optional) A token that allows processing to be cancelled. |
Returns
Name | Description |
---|---|
A task that represents the asynchronous get operation. |
Save()
Saves all changes made in this repository to the underlying database.
Returns
Name | Description |
---|---|
True if it succeeds, false if it fails. |
SaveAsync(CancellationToken)
Asynchronously saves all changes made in this repository to the underlying database.
Parameters
Name | Description |
---|---|
(Optional) A token that allows processing to be cancelled. |
Returns
Name | Description |
---|---|
A task that represents the asynchronous save operation. |
Update(TEntity)
Updates the given entity in the repository. Begins tracking the given entity in the Modified state such that it will be updated in the database when SaveChanges() is called.
Parameters
Name | Description |
---|---|
| The entity to update. |
Last updated