public async static Task <T> FindFirstOrDefaultAsync <T, U>(this ICosmosDbRepository <T> repo, IList <U> partitionKeys, Expression <Func <T, bool> > predicate = null, Func <IQueryable <T>, IQueryable <T> > clauses = null, FeedOptions feedOptions = null)
        {
            var results = (await Task.WhenAll(
                               partitionKeys.Select(partitionKey => repo.FindFirstOrDefaultAsync(predicate, clauses, SetPartitionKey(partitionKey, feedOptions)))))
                          .AsQueryable();

            if (results != default && clauses != default)
            {
                results = clauses.Invoke(results);
            }

            return(results.FirstOrDefault());
        }
Ejemplo n.º 2
0
 public static Task <T> FindFirstOrDefaultAsync <T, U>(this ICosmosDbRepository <T> repo, U partitionKey, Expression <Func <T, bool> > predicate = null, Func <IQueryable <T>, IQueryable <T> > clauses = null, FeedOptions feedOptions = null)
 {
     feedOptions = SetPartitionKey(partitionKey, feedOptions);
     return(repo.FindFirstOrDefaultAsync(predicate, clauses, feedOptions));
 }