-
-
Notifications
You must be signed in to change notification settings - Fork 0
easyextensionsentityframeworkcoredatabaserepository BaseRepositoryT
Create base repository based on database entity set with autosaving.
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph EasyExtensions.EntityFrameworkCore.Abstractions
EasyExtensions.EntityFrameworkCore.Abstractions.BaseEntity[[BaseEntity]]
class EasyExtensions.EntityFrameworkCore.Abstractions.BaseEntity abstractStyle;
end
subgraph EasyExtensions.EntityFrameworkCore.Database.Repository
EasyExtensions.EntityFrameworkCore.Database.Repository.BaseRepository_1[[BaseRepository< TItem >]]
class EasyExtensions.EntityFrameworkCore.Database.Repository.BaseRepository_1 abstractStyle;
EasyExtensions.EntityFrameworkCore.Database.Repository.BaseRepository_1TItem((TItem));
EasyExtensions.EntityFrameworkCore.Database.Repository.BaseRepository_1 -- where --o EasyExtensions.EntityFrameworkCore.Database.Repository.BaseRepository_1TItem
EasyExtensions.EntityFrameworkCore.Abstractions.BaseEntity --> EasyExtensions.EntityFrameworkCore.Database.Repository.BaseRepository_1TItem
EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository_1[[IRepository< TItem >]]
class EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository_1 interfaceStyle;
EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository_1TItem((TItem));
EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository_1 -- where --o EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository_1TItem
EasyExtensions.EntityFrameworkCore.Abstractions.BaseEntity --> EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository_1TItem
EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository[[IRepository]]
class EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository interfaceStyle;
end
EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository_1 --> EasyExtensions.EntityFrameworkCore.Database.Repository.BaseRepository_1
EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository --> EasyExtensions.EntityFrameworkCore.Database.Repository.IRepository_1
| Returns | Name |
|---|---|
Task<TItem> |
CreateAsync(TItem item) |
Task<bool> |
DeleteAsync(TItem item) |
Task<int> |
DeleteRangeAsync(IEnumerable<TItem> items) |
Task<Paging<TItem>> |
FilterAsync(...)Filters and paginates the entities asynchronously based on the specified query. |
Task<IEnumerable<TItem>> |
FindAsync(Expression<Func<TItem, bool>> predicate) |
Task<TItem> |
GetByIdAsync(int id)Retrieves an entity by its ID asynchronously. |
Task<IList<TItem>> |
ListAsync(...) |
IQueryable<TItem> |
Query()Get queryable database set. |
Task<int> |
SaveChangesAsync()Saves all changes made in the context to the underlying database asynchronously. |
Task<TItem> |
UpdateAsync(TItem item) |
Create base repository based on database entity set with autosaving.
-
IRepository<TItem> -
IRepository
protected BaseRepository(DbSet<TItem> db, Func<CancellationToken, Task<int>> saveChangesCallback)| Type | Name | Description |
|---|---|---|
DbSet<TItem> |
db | |
Func<CancellationToken, Task<int>> |
saveChangesCallback |
public BaseRepository(DbSet<TItem> db)| Type | Name | Description |
|---|---|---|
DbSet<TItem> |
db |
public virtual async Task<TItem> GetByIdAsync(int id)| Type | Name | Description |
|---|---|---|
int |
id | The ID of the entity. |
Retrieves an entity by its ID asynchronously.
A task that represents the asynchronous operation. The task result contains the entity with the specified ID.
public virtual async Task<TItem> CreateAsync(TItem item)| Type | Name | Description |
|---|---|---|
TItem |
item |
public virtual async Task<bool> DeleteAsync(TItem item)| Type | Name | Description |
|---|---|---|
TItem |
item |
public virtual async Task<int> DeleteRangeAsync(IEnumerable<TItem> items)| Type | Name | Description |
|---|---|---|
IEnumerable<TItem> |
items |
public virtual async Task<TItem> UpdateAsync(TItem item)| Type | Name | Description |
|---|---|---|
TItem |
item |
public virtual async Task<Paging<TItem>> FilterAsync(IGridifyQuery query)| Type | Name | Description |
|---|---|---|
IGridifyQuery |
query | The query parameters for filtering and pagination. |
Filters and paginates the entities asynchronously based on the specified query.
A task that represents the asynchronous operation. The task result contains the filtered and paginated entities.
public virtual async Task<Paging<TItem>> FilterAsync(IGridifyQuery query, IGridifyMapper<TItem> mapper)| Type | Name | Description |
|---|---|---|
IGridifyQuery |
query | |
IGridifyMapper<TItem> |
mapper |
public virtual Task<IEnumerable<TItem>> FindAsync(Expression<Func<TItem, bool>> predicate)| Type | Name | Description |
|---|---|---|
Expression<Func<TItem, bool>> |
predicate |
public virtual async Task<IList<TItem>> ListAsync(Expression<Func<TItem, bool>> predicate)| Type | Name | Description |
|---|---|---|
Expression<Func<TItem, bool>> |
predicate |
public virtual async Task<IList<TItem>> ListAsync()Gets all entities asynchronously.
A task that represents the asynchronous operation. The task result contains a collection of all entities.
public virtual async Task<int> SaveChangesAsync()Saves all changes made in the context to the underlying database asynchronously.
A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.
public virtual IQueryable<TItem> Query()Get queryable database set.
Queryable database set.
Generated with ModularDoc