Class MongoRepositoryBase<TId, TDocument, TFilter>
Base repository for reading and writing data from and to the mongo db
Inheritance
System.Object
MongoReadOnlyRepositoryBase<TId, TDocument, TFilter>
MongoRepositoryBase<TId, TDocument, TFilter>
Implements
IRepository<TId, TDocument, TFilter>
IReadOnlyRepository<TId, TDocument, TFilter>
System.IDisposable
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Simplic.Data.MongoDB
Assembly: Simplic.Data.MongoDB.dll
Syntax
public abstract class MongoRepositoryBase<TId, TDocument, TFilter> : MongoReadOnlyRepositoryBase<TId, TDocument, TFilter>, IRepository<TId, TDocument, TFilter>, IReadOnlyRepository<TId, TDocument, TFilter>, IDisposable where TDocument : IDocument<TId> where TFilter : IFilter<TId>, new()
Type Parameters
Name | Description |
---|---|
TId | Type of the key |
TDocument | Document type |
TFilter | Filter type |
Constructors
| Improve this Doc View SourceMongoRepositoryBase(IMongoContext)
Initialize base repository
Declaration
protected MongoRepositoryBase(IMongoContext context)
Parameters
Type | Name | Description |
---|---|---|
IMongoContext | context |
MongoRepositoryBase(IMongoContext, String)
initializes a new instance of MongoRepositoryBase<TId, TDocument, TFilter>
Declaration
protected MongoRepositoryBase(IMongoContext context, string configurationKey)
Parameters
Type | Name | Description |
---|---|---|
IMongoContext | context | |
System.String | configurationKey |
Methods
| Improve this Doc View SourceCommitAsync()
Commit data
Declaration
public virtual async Task<int> CommitAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | Amount of changed data |
CreateAsync(TDocument)
Create new entity
Declaration
public virtual async Task CreateAsync(TDocument document)
Parameters
Type | Name | Description |
---|---|---|
TDocument | document | Entity to create |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
CreateAsync(TDocument, ITransaction)
Adds creation of a new entity to transaction.
Declaration
public virtual async Task CreateAsync(TDocument document, ITransaction transaction)
Parameters
Type | Name | Description |
---|---|---|
TDocument | document | Entity to add. |
ITransaction | transaction | Transaction. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
DeleteAsync(TId)
Mark entity as deleted in database
Declaration
public virtual async Task DeleteAsync(TId id)
Parameters
Type | Name | Description |
---|---|---|
TId | id | Entity id |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
DeleteAsync(TId, ITransaction)
Adds deletion of an entity into transaction.
Declaration
public virtual async Task DeleteAsync(TId id, ITransaction transaction)
Parameters
Type | Name | Description |
---|---|---|
TId | id | |
ITransaction | transaction |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
GetFilterById(TId)
Gets base filter using an entity id
Declaration
protected FilterDefinition<TDocument> GetFilterById(TId id)
Parameters
Type | Name | Description |
---|---|---|
TId | id | Unique entity id |
Returns
Type | Description |
---|---|
FilterDefinition<TDocument> | Filter instance |
UpdateAsync(TDocument)
Update an entity in the database
Declaration
public virtual async Task UpdateAsync(TDocument document)
Parameters
Type | Name | Description |
---|---|---|
TDocument | document | The document with the updated values. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
UpdateAsync(TDocument, ITransaction)
Adds update of an entity into transaction.
Declaration
public virtual async Task UpdateAsync(TDocument document, ITransaction transaction)
Parameters
Type | Name | Description |
---|---|---|
TDocument | document | |
ITransaction | transaction |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
UpsertAsync(TFilter, TDocument)
Create or replace entity
Declaration
public async Task UpsertAsync(TFilter filter, TDocument entity)
Parameters
Type | Name | Description |
---|---|---|
TFilter | filter | Filter instance |
TDocument | entity | Entity instance |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Implements
System.IDisposable