107 lines
5.4 KiB
C#
107 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using MongoDbGenericRepository.Models;
|
|
|
|
namespace MongoDbGenericRepository
|
|
{
|
|
/// <summary>
|
|
/// The IBaseMongoRepository_Create interface to expose document creation functionality
|
|
/// with document having an Id of type Guid.
|
|
/// </summary>
|
|
public interface IBaseMongoRepository_Create : IBaseMongoRepository_Create<Guid>
|
|
{
|
|
/// <summary>
|
|
/// Asynchronously adds a document to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="document">The document you want to add.</param>
|
|
Task AddOneAsync<TDocument, TKey>(TDocument document)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Asynchronously adds a document to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="document">The document you want to add.</param>
|
|
/// <param name="cancellationToken">An optional cancellation Token.</param>
|
|
Task AddOneAsync<TDocument, TKey>(TDocument document, CancellationToken cancellationToken)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Adds a document to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="document">The document you want to add.</param>
|
|
void AddOne<TDocument, TKey>(TDocument document)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Adds a document to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="document">The document you want to add.</param>
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
void AddOne<TDocument, TKey>(TDocument document, CancellationToken cancellationToken)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Asynchronously adds a list of documents to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="documents">The documents you want to add.</param>
|
|
Task AddManyAsync<TDocument, TKey>(IEnumerable<TDocument> documents)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Asynchronously adds a list of documents to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="documents">The documents you want to add.</param>
|
|
/// <param name="cancellationToken">An optional cancellation Token.</param>
|
|
Task AddManyAsync<TDocument, TKey>(IEnumerable<TDocument> documents, CancellationToken cancellationToken)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Adds a list of documents to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="documents">The documents you want to add.</param>
|
|
void AddMany<TDocument, TKey>(IEnumerable<TDocument> documents)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
|
|
/// <summary>
|
|
/// Adds a list of documents to the collection.
|
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
|
/// </summary>
|
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
|
/// <param name="documents">The documents you want to add.</param>
|
|
/// <param name="cancellationToken">The cancellation token</param>
|
|
void AddMany<TDocument, TKey>(IEnumerable<TDocument> documents, CancellationToken cancellationToken)
|
|
where TDocument : IDocument<TKey>
|
|
where TKey : IEquatable<TKey>;
|
|
}
|
|
} |