|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Volo.Abp.Domain.Entities;
|
|
|
|
|
@ -23,20 +23,6 @@ namespace Volo.Abp.Domain.Repositories
|
|
|
|
|
public interface IRepository<TEntity, TPrimaryKey> : IRepository
|
|
|
|
|
where TEntity : class, IEntity<TPrimaryKey>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used to get all entities.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>List of all entities</returns>
|
|
|
|
|
[NotNull]
|
|
|
|
|
List<TEntity> GetList();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used to get all entities.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>List of all entities</returns>
|
|
|
|
|
[NotNull]
|
|
|
|
|
Task<List<TEntity>> GetListAsync();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an entity with given primary key.
|
|
|
|
|
/// Throws <see cref="EntityNotFoundException"/> if can not find an entity with given id.
|
|
|
|
|
@ -51,9 +37,10 @@ namespace Volo.Abp.Domain.Repositories
|
|
|
|
|
/// Throws <see cref="EntityNotFoundException"/> if can not find an entity with given id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">Primary key of the entity to get</param>
|
|
|
|
|
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
|
|
|
|
|
/// <returns>Entity</returns>
|
|
|
|
|
[NotNull]
|
|
|
|
|
Task<TEntity> GetAsync(TPrimaryKey id);
|
|
|
|
|
Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken));
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an entity with given primary key or null if not found.
|
|
|
|
|
@ -67,8 +54,9 @@ namespace Volo.Abp.Domain.Repositories
|
|
|
|
|
/// Gets an entity with given primary key or null if not found.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">Primary key of the entity to get</param>
|
|
|
|
|
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
|
|
|
|
|
/// <returns>Entity or null</returns>
|
|
|
|
|
Task<TEntity> FindAsync(TPrimaryKey id);
|
|
|
|
|
Task<TEntity> FindAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken));
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Inserts a new entity.
|
|
|
|
|
@ -80,9 +68,10 @@ namespace Volo.Abp.Domain.Repositories
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Inserts a new entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
|
|
|
|
|
/// <param name="entity">Inserted entity</param>
|
|
|
|
|
[NotNull]
|
|
|
|
|
Task<TEntity> InsertAsync([NotNull] TEntity entity);
|
|
|
|
|
Task<TEntity> InsertAsync([NotNull] TEntity entity, CancellationToken cancellationToken = default(CancellationToken));
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Inserts a new entity and gets it's Id.
|
|
|
|
|
@ -98,9 +87,10 @@ namespace Volo.Abp.Domain.Repositories
|
|
|
|
|
/// It may require to save current unit of work
|
|
|
|
|
/// to be able to retrieve id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
|
|
|
|
|
/// <param name="entity">Entity</param>
|
|
|
|
|
/// <returns>Id of the entity</returns>
|
|
|
|
|
Task<TPrimaryKey> InsertAndGetIdAsync([NotNull] TEntity entity);
|
|
|
|
|
Task<TPrimaryKey> InsertAndGetIdAsync([NotNull] TEntity entity, CancellationToken cancellationToken = default(CancellationToken));
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates an existing entity.
|
|
|
|
|
@ -112,9 +102,10 @@ namespace Volo.Abp.Domain.Repositories
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates an existing entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
|
|
|
|
|
/// <param name="entity">Entity</param>
|
|
|
|
|
[NotNull]
|
|
|
|
|
Task<TEntity> UpdateAsync([NotNull] TEntity entity);
|
|
|
|
|
Task<TEntity> UpdateAsync([NotNull] TEntity entity, CancellationToken cancellationToken = default(CancellationToken));
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes an entity.
|
|
|
|
|
@ -125,8 +116,9 @@ namespace Volo.Abp.Domain.Repositories
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes an entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
|
|
|
|
|
/// <param name="entity">Entity to be deleted</param>
|
|
|
|
|
Task DeleteAsync([NotNull] TEntity entity);
|
|
|
|
|
Task DeleteAsync([NotNull] TEntity entity, CancellationToken cancellationToken = default(CancellationToken));
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes an entity by primary key.
|
|
|
|
|
@ -137,19 +129,8 @@ namespace Volo.Abp.Domain.Repositories
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes an entity by primary key.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
|
|
|
|
|
/// <param name="id">Primary key of the entity</param>
|
|
|
|
|
Task DeleteAsync(TPrimaryKey id);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets count of all entities in this repository.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>Count of entities</returns>
|
|
|
|
|
int Count();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets count of all entities in this repository.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>Count of entities</returns>
|
|
|
|
|
Task<int> CountAsync();
|
|
|
|
|
Task DeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|