using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository
{
///
/// read only repository interface
///
/// The key type
public interface IReadOnlyMongoRepository
where TKey : IEquatable
{
#region Read
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
Task GetByIdAsync(TKey id)
where TDocument : IDocument;
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
/// The cancellation token.
Task GetByIdAsync(TKey id, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
/// An optional partition key.
Task GetByIdAsync(TKey id, string partitionKey)
where TDocument : IDocument;
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
/// An optional partition key.
/// The cancellation token.
Task GetByIdAsync(TKey id, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
TDocument GetById(TKey id)
where TDocument : IDocument;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
/// The cancellation token.
TDocument GetById(TKey id, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
/// An optional partition key.
TDocument GetById(TKey id, string partitionKey)
where TDocument : IDocument;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
/// An optional partition key.
/// The cancellation token.
TDocument GetById(TKey id, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
Task GetOneAsync(Expression> filter)
where TDocument : IDocument;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// The cancellation token
Task GetOneAsync(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task GetOneAsync(Expression> filter, string partitionKey)
where TDocument : IDocument;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// The cancellation token
Task GetOneAsync(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
TDocument GetOne(Expression> filter)
where TDocument : IDocument;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// The cancellation token
TDocument GetOne(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
TDocument GetOne(Expression> filter, string partitionKey)
where TDocument : IDocument;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// The cancellation token
TDocument GetOne(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Returns a collection cursor.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
IFindFluent GetCursor(Expression> filter, string partitionKey = null)
where TDocument : IDocument;
///
/// Asynchronously returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
Task AnyAsync(Expression> filter)
where TDocument : IDocument;
///
/// Asynchronously returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// The cancellation token.
Task AnyAsync(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Asynchronously returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task AnyAsync(Expression> filter, string partitionKey)
where TDocument : IDocument;
///
/// Asynchronously returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// The cancellation token.
Task AnyAsync(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
bool Any(Expression> filter)
where TDocument : IDocument;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// The cancellation token
bool Any(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
bool Any(Expression> filter, string partitionKey)
where TDocument : IDocument;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// The cancellation token
bool Any(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Asynchronously returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
Task> GetAllAsync(Expression> filter)
where TDocument : IDocument;
///
/// Asynchronously returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// The cancellation token
Task> GetAllAsync(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Asynchronously returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task> GetAllAsync(Expression> filter, string partitionKey)
where TDocument : IDocument;
///
/// Asynchronously returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// The cancellation token
Task> GetAllAsync(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
List GetAll(Expression> filter)
where TDocument : IDocument;
///
/// Returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// The cancellation token.
List GetAll(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
List GetAll(Expression> filter, string partitionKey)
where TDocument : IDocument;
///
/// Returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// The cancellation token.
List GetAll(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Asynchronously counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
Task CountAsync(Expression> filter)
where TDocument : IDocument;
///
/// Asynchronously counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// The cancellation token.
Task CountAsync(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Asynchronously counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task CountAsync(Expression> filter, string partitionKey)
where TDocument : IDocument;
///
/// Asynchronously counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// The cancellation token.
Task CountAsync(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
long Count(Expression> filter)
where TDocument : IDocument;
///
/// Counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// The Cancellation token.
long Count(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
long Count(Expression> filter, string partitionKey)
where TDocument : IDocument;
///
/// Counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// The Cancellation token.
long Count(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
#endregion
#region Min / Max
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
Task GetByMaxAsync(Expression> filter, Expression> orderByDescending)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// The cancellation token.
Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// An optional partitionKey.
Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// An optional partitionKey.
/// The cancellation token.
Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
///
TDocument GetByMax(Expression> filter, Expression> orderByDescending)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// The cancellation token.
///
TDocument GetByMax(Expression> filter, Expression> orderByDescending, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// An optional partitionKey.
///
TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// An optional partitionKey.
/// The cancellation token.
///
TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
Task GetByMinAsync(Expression> filter, Expression> orderByAscending)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// The cancellation token.
Task GetByMinAsync(Expression> filter, Expression> orderByAscending, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
/// The cancellation token.
Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
TDocument GetByMin(Expression> filter, Expression> orderByAscending)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// The cancellation token.
TDocument GetByMin(Expression> filter, Expression> orderByAscending, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
TDocument GetByMin(Expression> filter, Expression> orderByAscending, string partitionKey)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the
/// filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
/// The cancellation token.
TDocument GetByMin(Expression> filter, Expression> orderByAscending, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// The cancellation token.
Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
/// The cancellation token.
Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
TValue GetMaxValue(Expression> filter, Expression> maxValueSelector)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// The cancellation token.
TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
/// The cancellation token.
TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument;
///
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
Task GetMinValueAsync(Expression> filter, Expression> minValueSelector)
where TDocument : IDocument