Browse Source

Merge branch 'dev' of https://github.com/abpframework/abp into feat/volo-5292

pull/7861/head
mehmet-erim 6 years ago
parent
commit
14657dea57
  1. 42
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs

42
framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs

@ -11,60 +11,58 @@ namespace Volo.Abp.Domain.Repositories
public static class MongoDbCoreRepositoryExtensions public static class MongoDbCoreRepositoryExtensions
{ {
[Obsolete("Use GetDatabaseAsync method.")] [Obsolete("Use GetDatabaseAsync method.")]
public static IMongoDatabase GetDatabase<TEntity, TKey>(this IBasicRepository<TEntity, TKey> repository) public static IMongoDatabase GetDatabase<TEntity>(this IReadOnlyBasicRepository<TEntity> repository)
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity
{ {
return repository.ToMongoDbRepository().Database; return repository.ToMongoDbRepository().Database;
} }
public static Task<IMongoDatabase> GetDatabaseAsync<TEntity, TKey>(this IBasicRepository<TEntity, TKey> repository, CancellationToken cancellationToken = default) public static Task<IMongoDatabase> GetDatabaseAsync<TEntity>(this IReadOnlyBasicRepository<TEntity> repository, CancellationToken cancellationToken = default)
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity
{ {
return repository.ToMongoDbRepository().GetDatabaseAsync(cancellationToken); return repository.ToMongoDbRepository().GetDatabaseAsync(cancellationToken);
} }
[Obsolete("Use GetCollectionAsync method.")] [Obsolete("Use GetCollectionAsync method.")]
public static IMongoCollection<TEntity> GetCollection<TEntity, TKey>(this IBasicRepository<TEntity, TKey> repository) public static IMongoCollection<TEntity> GetCollection<TEntity>(this IReadOnlyBasicRepository<TEntity> repository)
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity
{ {
return repository.ToMongoDbRepository().Collection; return repository.ToMongoDbRepository().Collection;
} }
public static Task<IMongoCollection<TEntity>> GetCollectionAsync<TEntity, TKey>(this IBasicRepository<TEntity, TKey> repository, CancellationToken cancellationToken = default) public static Task<IMongoCollection<TEntity>> GetCollectionAsync<TEntity>(this IReadOnlyBasicRepository<TEntity> repository, CancellationToken cancellationToken = default)
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity
{ {
return repository.ToMongoDbRepository().GetCollectionAsync(cancellationToken); return repository.ToMongoDbRepository().GetCollectionAsync(cancellationToken);
} }
[Obsolete("Use GetMongoQueryableAsync method.")] [Obsolete("Use GetMongoQueryableAsync method.")]
public static IMongoQueryable<TEntity> GetMongoQueryable<TEntity, TKey>(this IBasicRepository<TEntity, TKey> repository) public static IMongoQueryable<TEntity> GetMongoQueryable<TEntity>(this IReadOnlyBasicRepository<TEntity> repository)
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity
{ {
return repository.ToMongoDbRepository().GetMongoQueryable(); return repository.ToMongoDbRepository().GetMongoQueryable();
} }
public static Task<IMongoQueryable<TEntity>> GetMongoQueryableAsync<TEntity, TKey>(this IBasicRepository<TEntity, TKey> repository, CancellationToken cancellationToken = default) public static Task<IMongoQueryable<TEntity>> GetMongoQueryableAsync<TEntity>(this IReadOnlyBasicRepository<TEntity> repository, CancellationToken cancellationToken = default)
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity
{ {
return repository.ToMongoDbRepository().GetMongoQueryableAsync(cancellationToken); return repository.ToMongoDbRepository().GetMongoQueryableAsync(cancellationToken);
} }
public static Task<IAggregateFluent<TEntity>> GetAggregateAsync<TEntity, TKey>(this IBasicRepository<TEntity, TKey> repository, CancellationToken cancellationToken = default) public static Task<IAggregateFluent<TEntity>> GetAggregateAsync<TEntity>(this IReadOnlyBasicRepository<TEntity> repository, CancellationToken cancellationToken = default)
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity
{ {
return repository.ToMongoDbRepository().GetAggregateAsync(cancellationToken); return repository.ToMongoDbRepository().GetAggregateAsync(cancellationToken);
} }
public static IMongoDbRepository<TEntity, TKey> ToMongoDbRepository<TEntity, TKey>(this IBasicRepository<TEntity, TKey> repository) public static IMongoDbRepository<TEntity> ToMongoDbRepository<TEntity>(this IReadOnlyBasicRepository<TEntity> repository)
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity
{ {
var mongoDbRepository = repository as IMongoDbRepository<TEntity, TKey>; if (repository is IMongoDbRepository<TEntity> mongoDbRepository)
if (mongoDbRepository == null)
{ {
throw new ArgumentException("Given repository does not implement " + typeof(IMongoDbRepository<TEntity, TKey>).AssemblyQualifiedName, nameof(repository)); return mongoDbRepository;
} }
throw new ArgumentException("Given repository does not implement " + typeof(IMongoDbRepository<TEntity>).AssemblyQualifiedName, nameof(repository));
return mongoDbRepository;
} }
} }
} }

Loading…
Cancel
Save