Skip to main content

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>)

Imports a list of documents into the collection

Task<IBulkImportResult> BulkImportAsync(IOctoSession session, IEnumerable<TDocument> documents)

Parameters

session IOctoSession
The session object

documents IEnumerable<TDocument>
The list of documents to import

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

Task

InsertManyAsync(IOctoSession, IEnumerable<TDocument>)

Inserts multiple documents into the collection

Task InsertManyAsync(IOctoSession session, IEnumerable<TDocument> documents)

Parameters

session IOctoSession

documents IEnumerable<TDocument>

Returns

Task

UpdateManyAsync(IOctoSession, IEnumerable<TDocument>)

Updates multiple documents in the collection

Task UpdateManyAsync(IOctoSession session, IEnumerable<TDocument> documents)

Parameters

session IOctoSession
The session object

documents IEnumerable<TDocument>
A list of documents to update

Returns

Task

Remarks:

Attention! This method updates existing attributes of a document. Not mentioned (or null) attributes are not updated.

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

Task

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

Task

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

Task

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

DeleteManyAsync(IOctoSession, IEnumerable<TKey>)

Deletes documents with the given id

Task DeleteManyAsync(IOctoSession session, IEnumerable<TKey> keys)

Parameters

session IOctoSession
The session object

keys IEnumerable<TKey>
A list of unique keys of the documents

Returns

Task

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>

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

Task<TDerived>

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

Task<IQueryable<TDocument>>

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