Код: Выделить всё
private readonly IMongoCollection _sharedMongoCollection;
private IMongoQueryable SharedDbQueryableCollection { get; }
private readonly IMongoCollection _otherMongoCollection;
private IMongoQueryable otherDbQueryableCollection { get; }
SharedDbQueryableCollection = _sharedMongoCollection.AsQueryable();
otherDbQueryableCollection = _otherMongoCollection.AsQueryable();
public async Task GetAllAsync(Context context, string filterCondition,
uint? limit)
{
var sharedQuery = SharedDbQueryableCollection
.ApplyContext(context, _scopeConditionEnforcement)
.ApplyFilter(filterCondition, _scopeConditionEnforcement);
var otherQuery = otherDbQueryableCollection
.ApplyContext(context, _scopeConditionEnforcement)
.ApplyFilter(filterCondition, _scopeConditionEnforcement);
var sharedResult = _mongoDbRepository.GetAllAsync(sharedQuery);
var tenantResult = _mongoDbRepository.GetAllAsync(tenantQuery);
var result = (await Task.WhenAll(sharedResult, tenantResult))
.SelectMany(t => t).ToList();
return limit.HasValue ? result.Take((int)limit.Value) : result;
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... ection-net