using MongoDB.Driver; using MongoDbGenericRepository.DataAccess.Update; using MongoDbGenericRepository.Models; using System; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; namespace MongoDbGenericRepository { public abstract partial class BaseMongoRepository : IBaseMongoRepository_Update_ClientSession { /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The client session. /// The document with the modifications you want to persist. /// The optional cancellation token. /// A boolean value indicating success. public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return await MongoDbUpdater.UpdateOneAsync(session, modifiedDocument, cancellationToken); } /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The client session. /// The document with the modifications you want to persist. /// The optional cancellation token. /// A boolean value indicating success. public virtual bool UpdateOne(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return MongoDbUpdater.UpdateOne(session, modifiedDocument, cancellationToken); } /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The client session. /// The document to modify. /// The update definition. /// The optional cancellation token. /// A boolean value indicating success. public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return await MongoDbUpdater.UpdateOneAsync(session, documentToModify, update, cancellationToken); } /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The client session. /// The document to modify. /// The update definition. /// The optional cancellation token. /// A boolean value indicating success. public virtual bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return MongoDbUpdater.UpdateOne(session, documentToModify, update, cancellationToken); } /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The document to modify. /// The field to update. /// The value of the field. /// The optional cancellation token. /// A boolean value indicating success. public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return await MongoDbUpdater.UpdateOneAsync(session, documentToModify, field, value, cancellationToken); } /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The document to modify. /// The field to update. /// The value of the field. /// The optional cancellation token. /// A boolean value indicating success. public virtual bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return MongoDbUpdater.UpdateOne(session, documentToModify, field, value, cancellationToken); } /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The filter for the update. /// The field to update. /// The value of the field. /// The optional partition key. /// The optional cancellation token. /// A boolean value indicating success. public virtual async Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return await MongoDbUpdater.UpdateOneAsync(session, filter, field, value, partitionKey, cancellationToken); } /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The filter for the update. /// The field to update. /// The value of the field. /// The optional partition key. /// The optional cancellation token. /// A boolean value indicating success. public virtual async Task UpdateOneAsync(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return await MongoDbUpdater.UpdateOneAsync(session, filter, field, value, partitionKey, cancellationToken); } /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The filter for the update. /// The field to update. /// The value of the field. /// The optional partition key. /// The optional cancellation token. /// A boolean value indicating success. public virtual bool UpdateOne(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return MongoDbUpdater.UpdateOne(session, filter, field, value, partitionKey, cancellationToken); } /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The filter for the update. /// The field to update. /// The value of the field. /// The optional partition key. /// The optional cancellation token. /// A boolean value indicating success. public virtual bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable { return UpdateOne(session, Builders.Filter.Where(filter), field, value, partitionKey, cancellationToken); } } }