Add CancellationToken support to IRepository methods
Updated the IRepository<TEntity> interface to include an optional CancellationToken parameter in the asynchronous methods: CreateAsync, ReadAsync, UpdateAsync, and DeleteAsync. Modified the DbRepository<TDbContext, TEntity> class to align with these changes, ensuring method signatures are consistent with the interface.
This commit is contained in:
@@ -4,13 +4,13 @@ namespace DigitalData.Core.Abstractions.Infrastructure;
|
|||||||
|
|
||||||
public interface IRepository<TEntity>
|
public interface IRepository<TEntity>
|
||||||
{
|
{
|
||||||
public Task<TEntity> CreateAsync<TDto>(TDto dto);
|
public Task<TEntity> CreateAsync<TDto>(TDto dto, CancellationToken ct = default);
|
||||||
|
|
||||||
public Task<TEntity> CreateAsync<TDto>(IEnumerable<TDto> dtos);
|
public Task<TEntity> CreateAsync<TDto>(IEnumerable<TDto> dtos, CancellationToken ct = default);
|
||||||
|
|
||||||
public Task<IEnumerable<TEntity>> ReadAsync(Expression? expression = null);
|
public Task<IEnumerable<TEntity>> ReadAsync(Expression? expression = null, CancellationToken ct = default);
|
||||||
|
|
||||||
public Task<IEnumerable<TEntity>> UpdateAsync<TDto>(TDto dto, Expression expression);
|
public Task<IEnumerable<TEntity>> UpdateAsync<TDto>(TDto dto, Expression expression, CancellationToken ct = default);
|
||||||
|
|
||||||
public Task<IEnumerable<TEntity>> DeleteAsync<TDto>(Expression expression);
|
public Task<IEnumerable<TEntity>> DeleteAsync<TDto>(Expression expression, CancellationToken ct = default);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,27 +16,27 @@ public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbC
|
|||||||
Entities = queryFactory(context);
|
Entities = queryFactory(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<TEntity> CreateAsync<TDto>(TDto dto)
|
public Task<TEntity> CreateAsync<TDto>(TDto dto, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<TEntity> CreateAsync<TDto>(IEnumerable<TDto> dtos)
|
public Task<TEntity> CreateAsync<TDto>(IEnumerable<TDto> dtos, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IEnumerable<TEntity>> DeleteAsync<TDto>(Expression expression)
|
public Task<IEnumerable<TEntity>> DeleteAsync<TDto>(Expression expression, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IEnumerable<TEntity>> ReadAsync(Expression? expression = null)
|
public Task<IEnumerable<TEntity>> ReadAsync(Expression? expression = null, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IEnumerable<TEntity>> UpdateAsync<TDto>(TDto dto, Expression expression)
|
public Task<IEnumerable<TEntity>> UpdateAsync<TDto>(TDto dto, Expression expression, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user