Use async methods in the blob repo.

pull/6809/head
Halil İbrahim Kalkan 4 years ago
parent 1525246a4d
commit 4d4121a313

@ -10,14 +10,15 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore
{
public class EfCoreDatabaseBlobContainerRepository : EfCoreRepository<IBlobStoringDbContext, DatabaseBlobContainer, Guid>, IDatabaseBlobContainerRepository
{
public EfCoreDatabaseBlobContainerRepository(IDbContextProvider<IBlobStoringDbContext> dbContextProvider)
public EfCoreDatabaseBlobContainerRepository(IDbContextProvider<IBlobStoringDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public virtual async Task<DatabaseBlobContainer> FindAsync(string name, CancellationToken cancellationToken = default)
{
return await DbSet.FirstOrDefaultAsync(x => x.Name == name, GetCancellationToken(cancellationToken));
return await (await GetDbSetAsync())
.FirstOrDefaultAsync(x => x.Name == name, GetCancellationToken(cancellationToken));
}
}
}
}

@ -20,7 +20,8 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore
string name,
CancellationToken cancellationToken = default)
{
return await DbSet.FirstOrDefaultAsync(
return await (await GetDbSetAsync())
.FirstOrDefaultAsync(
x => x.ContainerId == containerId && x.Name == name,
GetCancellationToken(cancellationToken)
);
@ -31,9 +32,11 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore
string name,
CancellationToken cancellationToken = default)
{
return await DbSet.AnyAsync(
x => x.ContainerId == containerId && x.Name == name,
GetCancellationToken(cancellationToken));
return await (await GetDbSetAsync())
.AnyAsync(
x => x.ContainerId == containerId && x.Name == name,
GetCancellationToken(cancellationToken)
);
}
public virtual async Task<bool> DeleteAsync(
@ -54,4 +57,4 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore
return true;
}
}
}
}

@ -15,35 +15,41 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB
public virtual async Task<DatabaseBlob> FindAsync(Guid containerId, string name, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().FirstOrDefaultAsync(
x => x.ContainerId == containerId &&
x.Name == name,
GetCancellationToken(cancellationToken));
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
.FirstOrDefaultAsync(
x => x.ContainerId == containerId && x.Name == name,
cancellationToken
);
}
public virtual async Task<bool> ExistsAsync(Guid containerId, string name, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().AnyAsync(
x => x.ContainerId == containerId &&
x.Name == name,
GetCancellationToken(cancellationToken));
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
.AnyAsync(
x => x.ContainerId == containerId && x.Name == name,
cancellationToken
);
}
public virtual async Task<bool> DeleteAsync(
Guid containerId,
Guid containerId,
string name,
bool autoSave = false,
CancellationToken cancellationToken = default)
{
var blob = await FindAsync(containerId, name, cancellationToken);
if (blob == null)
{
return false;
}
await base.DeleteAsync(blob, autoSave, cancellationToken: GetCancellationToken(cancellationToken));
await base.DeleteAsync(blob, autoSave, cancellationToken);
return true;
}
}
}
}

Loading…
Cancel
Save