Browse Source

Enabled entity, repo and aggr root without pk.

pull/194/head
Halil İbrahim Kalkan 8 years ago
parent
commit
5bd4c78bd8
  1. BIN
      src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll
  2. 13
      src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/AggregateRoot.cs
  3. 27
      src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/Entity.cs
  4. 20
      src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/IAggregateRoot.cs
  5. 21
      src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/IEntity.cs
  6. 15
      src/Volo.Abp.Ddd/Volo/Abp/Domain/Repositories/IQueryableRepository.cs
  7. 87
      src/Volo.Abp.Ddd/Volo/Abp/Domain/Repositories/IRepository.cs
  8. 84
      src/Volo.Abp.Ddd/Volo/Abp/Domain/Repositories/QueryableRepositoryBase.cs
  9. 86
      src/Volo.Abp.Ddd/Volo/Abp/Domain/Repositories/RepositoryBase.cs
  10. 22
      src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
  11. 5
      src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EfCoreIdentityRoleRepository.cs
  12. 5
      src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EfCoreIdentityUserRepository.cs
  13. 12
      src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
  14. 2
      src/Volo.Abp.Threading/Volo/Abp/Threading/CancellationTokenProviderExtensions.cs
  15. 10
      test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs

BIN
src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll

Binary file not shown.

13
src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/AggregateRoot.cs

@ -1,12 +1,13 @@
using System;
namespace Volo.Abp.Domain.Entities
namespace Volo.Abp.Domain.Entities
{
//public abstract class AggregateRoot : AggregateRoot<Guid>, IAggregateRoot
//{
//}
/// <inheritdoc cref="IAggregateRoot" />
public abstract class AggregateRoot : IAggregateRoot
{
}
/// <inheritdoc cref="IAggregateRoot{TPrimaryKey}" />
public abstract class AggregateRoot<TPrimaryKey> : Entity<TPrimaryKey>, IAggregateRoot<TPrimaryKey>
{

27
src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/Entity.cs

@ -1,23 +1,15 @@
using System;
using System.Reflection;
using System.Reflection;
namespace Volo.Abp.Domain.Entities
{
///// <summary>
///// A shortcut of <see cref="Entity{TPrimaryKey}"/> for default primary key type (<see cref="Guid"/>).
///// </summary>
//public abstract class Entity : Entity<Guid>, IEntity
//{
/// <inheritdoc/>
public abstract class Entity : IEntity
{
//}
}
/// <inheritdoc/>
/// <summary>
/// Basic implementation of IEntity interface.
/// An entity can inherit this class of directly implement to IEntity interface.
/// </summary>
/// <typeparam name="TPrimaryKey">Type of the primary key of the entity</typeparam>
public abstract class Entity<TPrimaryKey> : IEntity<TPrimaryKey>
/// <inheritdoc cref="IEntity{TPrimaryKey}" />
public abstract class Entity<TPrimaryKey> : Entity, IEntity<TPrimaryKey>
{
/// <inheritdoc/>
public virtual TPrimaryKey Id { get; set; }
@ -57,6 +49,11 @@ namespace Volo.Abp.Domain.Entities
/// <inheritdoc/>
public override int GetHashCode()
{
if (Id == null)
{
return 0;
}
return Id.GetHashCode();
}

20
src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/IAggregateRoot.cs

@ -1,13 +1,19 @@
using System;
namespace Volo.Abp.Domain.Entities
namespace Volo.Abp.Domain.Entities
{
//public interface IAggregateRoot : IAggregateRoot<Guid>, IEntity
//{
/// <summary>
/// Defines an aggregate root. It's primary key may not be "Id" or it may have a composite primary key.
/// Use <see cref="IAggregateRoot{TPrimaryKey}"/> where possible for better integration to repositories and other structures in the framework.
/// </summary>
public interface IAggregateRoot : IEntity
{
//}
}
public interface IAggregateRoot<TPrimaryKey> : IEntity<TPrimaryKey>
/// <summary>
/// Defines an aggregate root with a single primary key with "Id" property.
/// </summary>
/// <typeparam name="TPrimaryKey">Type of the primary key of the entity</typeparam>
public interface IAggregateRoot<TPrimaryKey> : IAggregateRoot, IEntity<TPrimaryKey>
{
}

21
src/Volo.Abp.Ddd/Volo/Abp/Domain/Entities/IEntity.cs

@ -1,20 +1,19 @@
using System;
namespace Volo.Abp.Domain.Entities
namespace Volo.Abp.Domain.Entities
{
///// <summary>
///// A shortcut of <see cref="IEntity{TPrimaryKey}"/> for default primary key type (<see cref="string"/>).
///// </summary>
//public interface IEntity : IEntity<Guid>
//{
/// <summary>
/// Defines an entity. It's primary key may not be "Id" or it mah have a composite primary key.
/// Use <see cref="IEntity{TPrimaryKey}"/> where possible for better integration to repositories and other structures in the framework.
/// </summary>
public interface IEntity
{
//}
}
/// <summary>
/// Defines interface for base entity type. All entities in the system must implement this interface.
/// Defines an entity with a single primary key with "Id" property.
/// </summary>
/// <typeparam name="TPrimaryKey">Type of the primary key of the entity</typeparam>
public interface IEntity<TPrimaryKey>
public interface IEntity<TPrimaryKey> : IEntity
{
/// <summary>
/// Unique identifier for this entity.

15
src/Volo.Abp.Ddd/Volo/Abp/Domain/Repositories/IQueryableRepository.cs

@ -8,14 +8,8 @@ using Volo.Abp.Domain.Entities;
namespace Volo.Abp.Domain.Repositories
{
//public interface IQueryableRepository<TEntity> : IQueryableRepository<TEntity, Guid>, IRepository<TEntity>
// where TEntity : class, IEntity<Guid>
//{
//}
public interface IQueryableRepository<TEntity, TPrimaryKey> : IRepository<TEntity, TPrimaryKey>, IQueryable<TEntity>
where TEntity : class, IEntity<TPrimaryKey>
public interface IQueryableRepository<TEntity> : IRepository<TEntity>, IQueryable<TEntity>
where TEntity : class, IEntity
{
/// <summary>
/// Deletes many entities by function.
@ -36,4 +30,9 @@ namespace Volo.Abp.Domain.Repositories
/// <param name="predicate">A condition to filter entities</param>
Task DeleteAsync([NotNull] Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
}
public interface IQueryableRepository<TEntity, TPrimaryKey> : IQueryableRepository<TEntity>, IRepository<TEntity, TPrimaryKey>
where TEntity : class, IEntity<TPrimaryKey>
{
}
}

87
src/Volo.Abp.Ddd/Volo/Abp/Domain/Repositories/IRepository.cs

@ -6,55 +6,17 @@ using Volo.Abp.Domain.Entities;
namespace Volo.Abp.Domain.Repositories
{
/// <summary>
/// Just to mark a class as repository.
/// </summary>
public interface IRepository : ITransientDependency
{
}
//public interface IRepository<TEntity> : IRepository<TEntity, Guid>
// where TEntity : class, IEntity<Guid>
//{
//}
public interface IRepository<TEntity, TPrimaryKey> : IRepository
where TEntity : class, IEntity<TPrimaryKey>
public interface IRepository<TEntity> : IRepository
where TEntity : class, IEntity
{
/// <summary>
/// Gets an entity with given primary key.
/// 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>
/// <returns>Entity</returns>
[NotNull]
TEntity Get(TPrimaryKey id);
/// <summary>
/// Gets an entity with given primary key.
/// 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, CancellationToken cancellationToken = default);
/// <summary>
/// Gets an entity with given primary key or null if not found.
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity or null</returns>
[CanBeNull]
TEntity Find(TPrimaryKey id); //TODO: Rename to FirstOrDefault..?
/// <summary>
/// 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, CancellationToken cancellationToken = default);
/// <summary>
/// Inserts a new entity.
/// </summary>
@ -105,6 +67,45 @@ namespace Volo.Abp.Domain.Repositories
/// <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, CancellationToken cancellationToken = default); //TODO: Return true if deleted
}
public interface IRepository<TEntity, TPrimaryKey> : IRepository<TEntity>
where TEntity : class, IEntity<TPrimaryKey>
{
/// <summary>
/// Gets an entity with given primary key.
/// 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>
/// <returns>Entity</returns>
[NotNull]
TEntity Get(TPrimaryKey id);
/// <summary>
/// Gets an entity with given primary key.
/// 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, CancellationToken cancellationToken = default);
/// <summary>
/// Gets an entity with given primary key or null if not found.
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity or null</returns>
[CanBeNull]
TEntity Find(TPrimaryKey id);
/// <summary>
/// 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, CancellationToken cancellationToken = default);
/// <summary>
/// Deletes an entity by primary key.

84
src/Volo.Abp.Ddd/Volo/Abp/Domain/Repositories/QueryableRepositoryBase.cs

@ -11,14 +11,8 @@ using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Domain.Repositories
{
//public abstract class QueryableRepositoryBase<TEntity> : QueryableRepositoryBase<TEntity, Guid>, IQueryableRepository<TEntity>
// where TEntity : class, IEntity<Guid>
//{
//}
public abstract class QueryableRepositoryBase<TEntity, TPrimaryKey> : RepositoryBase<TEntity, TPrimaryKey>, IQueryableRepository<TEntity, TPrimaryKey>
where TEntity : class, IEntity<TPrimaryKey>
public abstract class QueryableRepositoryBase<TEntity> : RepositoryBase<TEntity>, IQueryableRepository<TEntity>
where TEntity : class, IEntity
{
public virtual Type ElementType => GetQueryable().ElementType;
@ -26,10 +20,6 @@ namespace Volo.Abp.Domain.Repositories
public virtual IQueryProvider Provider => GetQueryable().Provider;
public IDataFilter DataFilter { get; set; }
public ICurrentTenant CurrentTenant { get; set; }
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
@ -42,33 +32,70 @@ namespace Volo.Abp.Domain.Repositories
protected abstract IQueryable<TEntity> GetQueryable();
public override List<TEntity> GetList()
public virtual void Delete(Expression<Func<TEntity, bool>> predicate)
{
return GetQueryable().ToList();
foreach (var entity in GetQueryable().Where(predicate).ToList())
{
Delete(entity);
}
}
public override TEntity Find(TPrimaryKey id)
public virtual Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default)
{
Delete(predicate);
return Task.CompletedTask;
}
}
public abstract class QueryableRepositoryBase<TEntity, TPrimaryKey> : QueryableRepositoryBase<TEntity>, IQueryableRepository<TEntity, TPrimaryKey>
where TEntity : class, IEntity<TPrimaryKey>
{
public IDataFilter DataFilter { get; set; }
public ICurrentTenant CurrentTenant { get; set; }
public virtual TEntity Find(TPrimaryKey id)
{
return GetQueryable().FirstOrDefault(CreateEqualityExpressionForId(id));
}
public virtual void Delete(Expression<Func<TEntity, bool>> predicate)
public virtual TEntity Get(TPrimaryKey id)
{
foreach (var entity in GetQueryable().Where(predicate).ToList())
var entity = Find(id);
if (entity == null)
{
Delete(entity);
throw new EntityNotFoundException(typeof(TEntity), id);
}
return entity;
}
public virtual Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default)
public virtual Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default)
{
Delete(predicate);
return Task.CompletedTask;
return Task.FromResult(Get(id));
}
public override long GetCount()
public virtual Task<TEntity> FindAsync(TPrimaryKey id, CancellationToken cancellationToken = default)
{
return GetQueryable().LongCount();
return Task.FromResult(Find(id));
}
public virtual void Delete(TPrimaryKey id)
{
var entity = Find(id);
if (entity == null)
{
return;
}
Delete(entity);
}
public virtual Task DeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default)
{
Delete(id);
return Task.CompletedTask;
}
protected virtual IQueryable<TEntity> ApplyDataFilters(IQueryable<TEntity> query)
@ -86,5 +113,16 @@ namespace Volo.Abp.Domain.Repositories
return query;
}
protected static Expression<Func<TEntity, bool>> CreateEqualityExpressionForId(TPrimaryKey id)
{
var lambdaParam = Expression.Parameter(typeof(TEntity));
var lambdaBody = Expression.Equal(
Expression.PropertyOrField(lambdaParam, "Id"),
Expression.Constant(id, typeof(TPrimaryKey))
);
return Expression.Lambda<Func<TEntity, bool>>(lambdaBody, lambdaParam);
}
}
}

86
src/Volo.Abp.Ddd/Volo/Abp/Domain/Repositories/RepositoryBase.cs

@ -1,21 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Threading;
namespace Volo.Abp.Domain.Repositories
{
//public abstract class RepositoryBase<TEntity> : RepositoryBase<TEntity, Guid>, IRepository<TEntity>
// where TEntity : class, IEntity<Guid>
//{
//}
public abstract class RepositoryBase<TEntity, TPrimaryKey> : IRepository<TEntity, TPrimaryKey>
where TEntity : class, IEntity<TPrimaryKey>
public abstract class RepositoryBase<TEntity> : IRepository<TEntity>
where TEntity : class, IEntity
{
public ICancellationTokenProvider CancellationTokenProvider { get; set; }
@ -24,13 +15,37 @@ namespace Volo.Abp.Domain.Repositories
CancellationTokenProvider = NullCancellationTokenProvider.Instance;
}
public abstract List<TEntity> GetList();
public abstract TEntity Insert(TEntity entity, bool autoSave = false);
public virtual Task<List<TEntity>> GetListAsync(CancellationToken cancellationToken = default)
public virtual Task<TEntity> InsertAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
{
return Task.FromResult(GetList());
return Task.FromResult(Insert(entity, autoSave));
}
public abstract TEntity Update(TEntity entity);
public virtual Task<TEntity> UpdateAsync(TEntity entity, CancellationToken cancellationToken = default)
{
return Task.FromResult(Update(entity));
}
public abstract void Delete(TEntity entity);
public virtual Task DeleteAsync(TEntity entity, CancellationToken cancellationToken = default)
{
Delete(entity);
return Task.CompletedTask;
}
protected virtual CancellationToken GetCancellationToken(CancellationToken prefferedValue = default)
{
return CancellationTokenProvider.FallbackToProvider(prefferedValue);
}
}
public abstract class RepositoryBase<TEntity, TPrimaryKey> : RepositoryBase<TEntity>, IRepository<TEntity, TPrimaryKey>
where TEntity : class, IEntity<TPrimaryKey>
{
public virtual TEntity Get(TPrimaryKey id)
{
var entity = Find(id);
@ -55,28 +70,6 @@ namespace Volo.Abp.Domain.Repositories
return Task.FromResult(Find(id));
}
public abstract TEntity Insert(TEntity entity, bool autoSave = false);
public virtual Task<TEntity> InsertAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
{
return Task.FromResult(Insert(entity, autoSave));
}
public abstract TEntity Update(TEntity entity);
public virtual Task<TEntity> UpdateAsync(TEntity entity, CancellationToken cancellationToken = default)
{
return Task.FromResult(Update(entity));
}
public abstract void Delete(TEntity entity);
public virtual Task DeleteAsync(TEntity entity, CancellationToken cancellationToken = default)
{
Delete(entity);
return Task.CompletedTask;
}
public virtual void Delete(TPrimaryKey id)
{
var entity = Find(id);
@ -93,24 +86,5 @@ namespace Volo.Abp.Domain.Repositories
Delete(id);
return Task.CompletedTask;
}
public abstract long GetCount();
public virtual Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return Task.FromResult(GetCount());
}
protected static Expression<Func<TEntity, bool>> CreateEqualityExpressionForId(TPrimaryKey id)
{
var lambdaParam = Expression.Parameter(typeof(TEntity));
var lambdaBody = Expression.Equal(
Expression.PropertyOrField(lambdaParam, "Id"),
Expression.Constant(id, typeof(TPrimaryKey))
);
return Expression.Lambda<Func<TEntity, bool>>(lambdaBody, lambdaParam);
}
}
}

22
src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs

@ -46,14 +46,9 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
return DbSet.AsQueryable();
}
public override Task<List<TEntity>> GetListAsync(CancellationToken cancellationToken = default)
{
return DbSet.ToListAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
}
public override async Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default)
{
var entity = await FindAsync(id, CancellationTokenProvider.FallbackToProvider(cancellationToken));
var entity = await FindAsync(id, GetCancellationToken(cancellationToken));
if (entity == null)
{
@ -70,7 +65,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
public override Task<TEntity> FindAsync(TPrimaryKey id, CancellationToken cancellationToken = default)
{
return DbSet.FindAsync(new object[] { id }, CancellationTokenProvider.FallbackToProvider(cancellationToken));
return DbSet.FindAsync(new object[] { id }, GetCancellationToken(cancellationToken));
}
public override TEntity Insert(TEntity entity, bool autoSave = false)
@ -91,7 +86,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
if (autoSave)
{
await DbContext.SaveChangesAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
await DbContext.SaveChangesAsync(GetCancellationToken(cancellationToken));
}
return savedEntity;
@ -110,25 +105,20 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
public override async Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default)
{
var entities = await GetQueryable().Where(predicate).ToListAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
var entities = await GetQueryable().Where(predicate).ToListAsync(GetCancellationToken(cancellationToken));
foreach (var entity in entities)
{
DbSet.Remove(entity);
}
}
public override Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return GetQueryable().LongCountAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
}
public virtual Task EnsureCollectionLoadedAsync<TProperty>(
TEntity entity,
Expression<Func<TEntity, IEnumerable<TProperty>>> propertyExpression,
CancellationToken cancellationToken = default)
where TProperty : class
{
return DbContext.Entry(entity).Collection(propertyExpression).LoadAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
return DbContext.Entry(entity).Collection(propertyExpression).LoadAsync(GetCancellationToken(cancellationToken));
}
public virtual Task EnsurePropertyLoadedAsync<TProperty>(
@ -137,7 +127,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
CancellationToken cancellationToken = default)
where TProperty : class
{
return DbContext.Entry(entity).Reference(propertyExpression).LoadAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
return DbContext.Entry(entity).Reference(propertyExpression).LoadAsync(GetCancellationToken(cancellationToken));
}
}
}

5
src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EfCoreIdentityRoleRepository.cs

@ -30,5 +30,10 @@ namespace Volo.Abp.Identity
.PageBy(skipCount, maxResultCount)
.ToListAsync();
}
public async Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return await this.LongCountAsync(cancellationToken);
}
}
}

5
src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EfCoreIdentityUserRepository.cs

@ -107,5 +107,10 @@ namespace Volo.Abp.Identity
return await query.ToListAsync();
}
public async Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return await this.LongCountAsync(cancellationToken);
}
}
}

12
src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs

@ -37,13 +37,6 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
DatabaseProvider = databaseProvider;
}
//TODO: Override other methods?
public override async Task<List<TEntity>> GetListAsync(CancellationToken cancellationToken = new CancellationToken())
{
return await (await Collection.FindAsync(Builders<TEntity>.Filter.Empty, cancellationToken: cancellationToken)).ToListAsync(cancellationToken);
}
public override async Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default)
{
var entity = await FindAsync(id, cancellationToken);
@ -120,10 +113,5 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
{
return Collection.AsQueryable();
}
public override Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
return Collection.CountAsync(Builders<TEntity>.Filter.Empty, cancellationToken: cancellationToken);
}
}
}

2
src/Volo.Abp.Threading/Volo/Abp/Threading/CancellationTokenProviderExtensions.cs

@ -4,7 +4,7 @@ namespace Volo.Abp.Threading
{
public static class CancellationTokenProviderExtensions
{
public static CancellationToken FallbackToProvider(this ICancellationTokenProvider provider, CancellationToken prefferedValue)
public static CancellationToken FallbackToProvider(this ICancellationTokenProvider provider, CancellationToken prefferedValue = default)
{
return prefferedValue == default ? provider.Token : prefferedValue;
}

10
test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs

@ -164,16 +164,6 @@ namespace Volo.Abp.Domain.Repositories
{
throw new NotImplementedException();
}
public override long GetCount()
{
throw new NotImplementedException();
}
public override List<TEntity> GetList()
{
throw new NotImplementedException();
}
}
public class MyTestAggregateRootWithDefaultPkCustomRepository : MyTestDefaultRepository<MyTestAggregateRootWithGuidPk, Guid>

Loading…
Cancel
Save