Add CancellationToken optional parameter to the feature-management module repository methods

pull/7359/head
liangshiwei 5 years ago
parent 746dc8a1e0
commit 630c7610cf

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
@ -7,10 +8,21 @@ namespace Volo.Abp.FeatureManagement
{
public interface IFeatureValueRepository : IBasicRepository<FeatureValue, Guid>
{
Task<FeatureValue> FindAsync(string name, string providerName, string providerKey);
Task<FeatureValue> FindAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default);
Task<List<FeatureValue>> FindAllAsync(string name, string providerName, string providerKey);
Task<List<FeatureValue>> FindAllAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default);
Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey);
Task<List<FeatureValue>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default);
}
}

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
@ -15,29 +16,38 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore
{
}
public virtual async Task<FeatureValue> FindAsync(string name, string providerName, string providerKey)
public virtual async Task<FeatureValue> FindAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey
);
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, GetCancellationToken(cancellationToken));
}
public async Task<List<FeatureValue>> FindAllAsync(string name, string providerName, string providerKey)
public async Task<List<FeatureValue>> FindAllAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Where(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync();
).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey)
public virtual async Task<List<FeatureValue>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Where(
s => s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync();
).ToListAsync(GetCancellationToken(cancellationToken));
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
@ -16,24 +17,35 @@ namespace Volo.Abp.FeatureManagement.MongoDB
}
public virtual async Task<FeatureValue> FindAsync(string name, string providerName, string providerKey)
public virtual async Task<FeatureValue> FindAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync())
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey);
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, GetCancellationToken(cancellationToken));
}
public async Task<List<FeatureValue>> FindAllAsync(string name, string providerName, string providerKey)
public async Task<List<FeatureValue>> FindAllAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync())
.Where(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey).ToListAsync();
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey)
public virtual async Task<List<FeatureValue>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync())
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync();
.ToListAsync(GetCancellationToken(cancellationToken));
}
}
}

Loading…
Cancel
Save