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
{
///
/// The IBaseReadOnlyRepository exposes the generic Read Only functionality of the BaseMongoRepository.
///
public interface IBaseReadOnlyRepository
{
///
/// The connection string.
///
string ConnectionString { get; }
///
/// The database name.
///
string DatabaseName { get; }
#region Read TKey
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
Task GetByIdAsync(TKey id)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
/// An optional cancellation Token.
Task GetByIdAsync(TKey id, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
/// An optional partition key.
Task GetByIdAsync(TKey id, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
/// An optional partition key.
/// An optional cancellation Token.
Task GetByIdAsync(TKey id, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
TDocument GetById(TKey id)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
/// An optional cancellation token.
TDocument GetById(TKey id, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
/// An optional partition key.
TDocument GetById(TKey id, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
/// An optional partition key.
/// An optional cancellation token.
TDocument GetById(TKey id, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
Task GetOneAsync(FilterDefinition condition)
where TDocument : IDocument where TKey : IEquatable;
///
/// Asynchronously returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb filter option.
Task GetOneAsync(FilterDefinition condition, FindOptions findOption)
where TDocument : IDocument where TKey : IEquatable;
///
/// Asynchronously returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional partition key.
Task GetOneAsync(FilterDefinition condition, string partitionKey)
where TDocument : IDocument where TKey : IEquatable;
///
/// Asynchronously returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb filter option.
/// An optional partition key.
Task GetOneAsync(FilterDefinition condition, FindOptions findOption, string partitionKey)
where TDocument : IDocument where TKey : IEquatable;
///
/// Asynchronously returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional cancellation Token.
Task GetOneAsync(FilterDefinition condition, CancellationToken cancellationToken)
where TDocument : IDocument where TKey : IEquatable;
///
/// Asynchronously returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb filter option.
/// An optional cancellation Token.
Task GetOneAsync(FilterDefinition condition, FindOptions findOption, CancellationToken cancellationToken)
where TDocument : IDocument where TKey : IEquatable;
///
/// Asynchronously returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional partition key.
/// An optional cancellation Token.
Task GetOneAsync(FilterDefinition condition, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb filter option.
/// An optional partition key.
/// An optional cancellation Token.
Task GetOneAsync(
FilterDefinition condition,
FindOptions findOption,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
TDocument GetOne(FilterDefinition condition)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb filter option.
TDocument GetOne(FilterDefinition condition, FindOptions findOption)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional partition key.
TDocument GetOne(FilterDefinition condition, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb filter option.
/// An optional partition key.
TDocument GetOne(FilterDefinition condition, FindOptions findOption, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional cancellation token.
TDocument GetOne(FilterDefinition condition, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb filter option.
/// An optional cancellation token.
TDocument GetOne(FilterDefinition condition, FindOptions findOption, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional partition key.
/// An optional cancellation token.
TDocument GetOne(FilterDefinition condition, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given filter definition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb filter option.
/// An optional partition key.
/// An optional cancellation token.
TDocument GetOne(
FilterDefinition condition,
FindOptions findOption,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
Task GetOneAsync(Expression> filter)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional cancellation Token.
Task GetOneAsync(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task GetOneAsync(Expression> filter, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// An optional cancellation Token.
Task GetOneAsync(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
TDocument GetOne(Expression> filter)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional cancellation token.
TDocument GetOne(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
TDocument GetOne(Expression> filter, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// An optional cancellation token.
TDocument GetOne(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns a collection cursor.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
IFindFluent GetCursor(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional cancellation Token.
Task AnyAsync(FilterDefinition condition, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
Task AnyAsync(FilterDefinition condition)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional partition key.
Task AnyAsync(FilterDefinition condition, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb counting option.
Task AnyAsync(FilterDefinition condition, CountOptions countOption)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb counting option.
/// An optional partition key.
Task AnyAsync(FilterDefinition condition, CountOptions countOption, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional partition key.
/// An optional cancellation Token.
Task AnyAsync(FilterDefinition condition, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb counting option.
/// An optional cancellation Token.
Task AnyAsync(FilterDefinition condition, CountOptions countOption, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb counting option.
/// An optional partition key.
/// An optional cancellation Token.
Task AnyAsync(
FilterDefinition condition,
CountOptions countOption,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
bool Any(FilterDefinition condition)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional partition key.
bool Any(FilterDefinition condition, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb counting option.
bool Any(FilterDefinition condition, CountOptions countOption)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb counting option.
/// An optional partition key.
bool Any(FilterDefinition condition, CountOptions countOption, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional cancellation token.
bool Any(FilterDefinition condition, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// An optional partition key.
/// An optional cancellation token.
bool Any(FilterDefinition condition, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb counting option.
/// An optional cancellation token.
bool Any(FilterDefinition condition, CountOptions countOption, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
/// A mongodb counting option.
/// An optional partition key.
/// An optional cancellation token.
bool Any(FilterDefinition condition, CountOptions countOption, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
Task AnyAsync(Expression> filter)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional cancellation Token.
Task AnyAsync(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task AnyAsync(Expression> filter, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// An optional cancellation Token.
Task AnyAsync(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
bool Any(Expression> filter)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional cancellation Token.
bool Any(Expression> filter, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
bool Any(Expression> filter, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
/// An optional cancellation Token.
bool Any(Expression> filter, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A mongodb filter definition.
Task> GetAllAsync(FilterDefinition condition)
where TDocument : IDocument
where TKey : IEquatable;
///