IDataSourceCollection<TKey, TDocument>
Namespace: Meshmakers.Octo.Runtime.Contracts.Repositories
Interface for the management of a collection of entities in a data source
public interface IDataSourceCollection<TKey, TDocument>
Type Parameters
TKey
TDocument
Methods
BulkImportAsync(IOctoSession, IEnumerable<TDocument>, BulkOperationOptions)
Imports a list of documents into the collection
Task<IBulkImportResult> BulkImportAsync(IOctoSession session, IEnumerable<TDocument> documents, BulkOperationOptions options)
Parameters
session IOctoSession
The session object
documents IEnumerable<TDocument>
The list of documents to import
options BulkOperationOptions
Options for the bulk operation
Returns
Task<IBulkImportResult>
Returns the result of the import
InsertOneAsync(IOctoSession, TDocument)
Inserts a new document into the collection
Task InsertOneAsync(IOctoSession session, TDocument document)
Parameters
session IOctoSession
The session object
document TDocument
The document to insert
Returns
InsertManyAsync(IOctoSession, IEnumerable<TDocument>)
Inserts multiple documents into the collection
Task InsertManyAsync(IOctoSession session, IEnumerable<TDocument> documents)
Parameters
session IOctoSession
documents IEnumerable<TDocument>
Returns
UpdateOneAsync(IOctoSession, IEnumerable<TDocument>)
Updates multiple documents in the collection
Task UpdateOneAsync(IOctoSession session, IEnumerable<TDocument> documents)
Parameters
session IOctoSession
The session object
documents IEnumerable<TDocument>
A list of documents to update
Returns
Remarks:
Attention! This method updates existing attributes of a document. Not mentioned (or null) attributes are not updated.
UpdateManyAsync(IOctoSession, Expression<Func<TDocument, Boolean>>, TDocument)
Updates multiple documents in the collection based on a filter expression
Task UpdateManyAsync(IOctoSession session, Expression<Func<TDocument, bool>> expression, TDocument document)
Parameters
session IOctoSession
The session object
expression Expression<Func<TDocument, Boolean>>
Filter expression to filter for documents that need to be updated
document TDocument
Document template with new values
Returns
ReplaceManyAsync(IOctoSession, IEnumerable<TDocument>)
Replaces multiple documents in the collection
Task ReplaceManyAsync(IOctoSession session, IEnumerable<TDocument> documents)
Parameters
session IOctoSession
The session object
documents IEnumerable<TDocument>
A list of documents to replaced, based on the runtime object id
Returns
ReplaceByIdAsync(IOctoSession, TKey, TDocument)
Replace a document in the collection
Task ReplaceByIdAsync(IOctoSession session, TKey key, TDocument document)
Parameters
session IOctoSession
The session object
key TKey
The unique key
document TDocument
The document the existing of is replaced
Returns
DeleteOneAsync(IOctoSession, TKey)
Deletes the document with the given key
Task DeleteOneAsync(IOctoSession session, TKey key)
Parameters
session IOctoSession
The session object
key TKey
The unique key
Returns
TryDeleteOneAsync(IOctoSession, TKey)
Deletes the document with the given key without exceptions and with return value that indicates if the document has been deleted
Task<bool> TryDeleteOneAsync(IOctoSession session, TKey key)
Parameters
session IOctoSession
The session object
key TKey
The unique key
Returns
Task<Boolean>
True, when the document has been deleted, otherwise false
TryDeleteOneAsync(IOctoSession, Expression<Func<TDocument, Boolean>>)
Deletes the first document that matches the given expression without exceptions and with return value that indicates if the document has been deleted
Task<bool> TryDeleteOneAsync(IOctoSession session, Expression<Func<TDocument, bool>> expression)
Parameters
session IOctoSession
The session object
expression Expression<Func<TDocument, Boolean>>
Filter expression
Returns
Task<Boolean>
True, when the document has been deleted, otherwise false
DeleteOneAsync(IOctoSession, IEnumerable<TKey>)
Deletes documents with the given id
Task DeleteOneAsync(IOctoSession session, IEnumerable<TKey> keys)
Parameters
session IOctoSession
The session object
keys IEnumerable<TKey>
A list of unique keys of the documents
Returns
DeleteManyAsync(IOctoSession, Expression<Func<TDocument, Boolean>>)
Deletes all documents matching the given expression
Task DeleteManyAsync(IOctoSession session, Expression<Func<TDocument, bool>> expression)
Parameters
session IOctoSession
The session object
expression Expression<Func<TDocument, Boolean>>
Filter expression
Returns
DocumentAsync(IOctoSession, TKey)
Gets the document with the given key
Task<TDocument> DocumentAsync(IOctoSession session, TKey key)
Parameters
session IOctoSession
The session object
key TKey
The unique key
Returns
Task<TDocument>
The document or null if not found
DocumentsAsync(IOctoSession, IEnumerable<TKey>)
Gets the document with the given key
Task<IReadOnlyList<TDocument>> DocumentsAsync(IOctoSession session, IEnumerable<TKey> keys)
Parameters
session IOctoSession
The session object
keys IEnumerable<TKey>
A list of unique keys for the documents
Returns
Task<IReadOnlyList<TDocument>>
A list of documents
DocumentAsync<TDerived>(IOctoSession, TKey)
Gets the document with the given key
Task<TDerived> DocumentAsync<TDerived>(IOctoSession session, TKey key)
Type Parameters
TDerived
The type of the derived document
Parameters
session IOctoSession
The session object
key TKey
The unique key
Returns
AsQueryableAsync(IOctoSession)
Gets a queryable interface of the given type to the data source
Task<IQueryable<TDocument>> AsQueryableAsync(IOctoSession session)
Parameters
session IOctoSession
The session object
Returns
AsQueryable(IOctoSession)
Gets a queryable interface of the given type to the data source
IQueryable<TDocument> AsQueryable(IOctoSession session)
Parameters
session IOctoSession
The session object
Returns
IQueryable<TDocument>
FindSingleOrDefaultAsync(IOctoSession, Expression<Func<TDocument, Boolean>>)
Finds a document by the given expression
Task<TDocument> FindSingleOrDefaultAsync(IOctoSession session, Expression<Func<TDocument, bool>> expression)
Parameters
session IOctoSession
The session object
expression Expression<Func<TDocument, Boolean>>
Filter expression
Returns
Task<TDocument>
The document
FindManyAsync(IOctoSession, Expression<Func<TDocument, Boolean>>, Nullable<Int32>, Nullable<Int32>)
Finds a document by the given expression
Task<ICollection<TDocument>> FindManyAsync(IOctoSession session, Expression<Func<TDocument, bool>> expression, Nullable<int> skip, Nullable<int> take)
Parameters
session IOctoSession
The session object
expression Expression<Func<TDocument, Boolean>>
Filter expression
skip Nullable<Int32>
Amount of documents to skip
take Nullable<Int32>
Maximum amount of documents to return
Returns
Task<ICollection<TDocument>>
List of documents
GetTotalCountAsync(IOctoSession)
Gets the total count of documents in the collection
Task<long> GetTotalCountAsync(IOctoSession session)
Parameters
session IOctoSession
The session object
Returns
Task<Int64>
Total count
GetTotalCountAsync(IOctoSession, Expression<Func<TDocument, Boolean>>)
Gets the total count of documents in the collection that match the given filter
Task<long> GetTotalCountAsync(IOctoSession session, Expression<Func<TDocument, bool>> expression)
Parameters
session IOctoSession
The session object
expression Expression<Func<TDocument, Boolean>>
Filter expression
Returns
Task<Int64>
Total count
GetAsync(IOctoSession, Nullable<Int32>, Nullable<Int32>)
Gets all documents of the collection
Task<IEnumerable<TDocument>> GetAsync(IOctoSession session, Nullable<int> skip, Nullable<int> take)
Parameters
session IOctoSession
The session object
skip Nullable<Int32>
Amount of documents to skip
take Nullable<Int32>
Maximum amount of documents to return
Returns
Task<IEnumerable<TDocument>>
List of documents