/// <summary>
 /// Sums the values of a selected field for a given filtered collection of documents.
 /// </summary>
 /// <typeparam name="TDocument">The type representing a Document.</typeparam>
 /// <param name="filter">A LINQ expression filter.</param>
 /// <param name="selector">The field you want to sum.</param>
 /// <param name="partitionKey">The partition key of your document, if any.</param>
 public virtual async Task <int> SumByAsync <TDocument>(Expression <Func <TDocument, bool> > filter,
                                                        Expression <Func <TDocument, int> > selector,
                                                        string partitionKey = null)
     where TDocument : IDocument <TKey>
 {
     return(await MongoDbReader.SumByAsync <TDocument, TKey>(filter, selector, partitionKey));
 }
示例#2
0
 /// <summary>
 /// Sums the values of a selected field for a given filtered collection of documents.
 /// </summary>
 /// <typeparam name="TDocument">The type representing a Document.</typeparam>
 /// <typeparam name="TKey">The type of the primary key.</typeparam>
 /// <param name="filter">A LINQ expression filter.</param>
 /// <param name="selector">The field you want to sum.</param>
 /// <param name="partitionKey">The partition key of your document, if any.</param>
 /// <param name="cancellationToken">An optional cancellation Token.</param>
 public virtual async Task <int> SumByAsync <TDocument, TKey>(Expression <Func <TDocument, bool> > filter,
                                                              Expression <Func <TDocument, int> > selector,
                                                              string partitionKey = null,
                                                              CancellationToken cancellationToken = default)
     where TDocument : IDocument <TKey>
     where TKey : IEquatable <TKey>
 {
     return(await MongoDbReader.SumByAsync <TDocument, TKey>(filter, selector, partitionKey, cancellationToken));
 }