Gleeman.Repository.MongoDriver
7.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Gleeman.Repository.MongoDriver --version 7.0.0
NuGet\Install-Package Gleeman.Repository.MongoDriver -Version 7.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Gleeman.Repository.MongoDriver" Version="7.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Gleeman.Repository.MongoDriver --version 7.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Gleeman.Repository.MongoDriver, 7.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Gleeman.Repository.MongoDriver as a Cake Addin #addin nuget:?package=Gleeman.Repository.MongoDriver&version=7.0.0 // Install Gleeman.Repository.MongoDriver as a Cake Tool #tool nuget:?package=Gleeman.Repository.MongoDriver&version=7.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
GleemanRepository.MongoDriver
Command Repositories
Create
public interface IMongoCreateAsyncRepository<TCollection>
where TCollection : class
{
Task<TCollection> CreateAsync(TCollection document, CancellationToken cancellationToken = default(CancellationToken));
Task InsertAsync(TCollection document, CancellationToken cancellationToken = default(CancellationToken));
Task<IEnumerable<TCollection>> CreateRangeAsync(IEnumerable<TCollection> documents, CancellationToken cancellationToken = default(CancellationToken));
Task InsertRangeAsync(IEnumerable<TCollection> documents, CancellationToken cancellationToken = default(CancellationToken));
}
public interface IMongoCreateSyncRepository<TCollection>
where TCollection : class
{
TCollection Create(TCollection document);
void Insert(TCollection document);
IEnumerable<TCollection> CreateRange(IEnumerable<TCollection> documents);
void InsertRange(IEnumerable<TCollection> documents);
}
Delete
public interface IMongoDeleteAsyncRepository<TCollection>
where TCollection : class
{
Task DeleteAsync(FilterDefinition<TCollection> filter, CancellationToken cancellationToken = default(CancellationToken));
Task DeleteRangeAsync(FilterDefinition<TCollection> filter, CancellationToken cancellationToken = default(CancellationToken));
}
public interface IMongoDeleteSyncRepository<TCollection>
where TCollection : class
{
void Delete(FilterDefinition<TCollection> filter);
void DeleteRange(FilterDefinition<TCollection> filter);
}
Update
public interface IMongoUpdateAsyncRepository<TCollection>
where TCollection : class
{
Task<TCollection> UpdateAsync(FilterDefinition<TCollection> filter, TCollection collection, CancellationToken cancellationToken = default);
Task EditAsync(FilterDefinition<TCollection> filter, TCollection collection, CancellationToken cancellationToken = default);
Task EditRangeAsync(FilterDefinition<TCollection> filter, UpdateDefinition<TCollection> update, CancellationToken cancellationToken = default);
}
public interface IMongoUpdateSyncRepository<TCollection>
where TCollection : class
{
TCollection Update(FilterDefinition<TCollection> filter, TCollection collection);
void Edit(FilterDefinition<TCollection> filter, TCollection collection);
void EditRange(FilterDefinition<TCollection> filter, UpdateDefinition<TCollection> update);
}
Query Repositories
public interface IMongoQueryAsyncRepository<TCollection>
where TCollection : class
{
Task<IEnumerable<TCollection>> ReadAllAsync(CancellationToken cancellationToken = default(CancellationToken),
Expression<Func<TCollection, bool>> filter = null,
Action<Pagination> pagination = null);
Task<TCollection> ReadSingleOrDefaultAsync(Expression<Func<TCollection, bool>> filter,
CancellationToken cancellationToken = default(CancellationToken));
Task<TCollection> ReadFirstOrDefaultAsync(Expression<Func<TCollection, bool>> filter,
CancellationToken cancellationToken = default(CancellationToken));
Task<TCollection> ReadSingleAsync(Expression<Func<TCollection, bool>> filter,
CancellationToken cancellationToken = default(CancellationToken));
Task<TCollection> ReadFirstAsync(Expression<Func<TCollection, bool>> filter,
CancellationToken cancellationToken = default(CancellationToken));
}
public interface IMongoQuerySyncRepository<TCollection>
where TCollection : class
{
IEnumerable<TCollection> ReadAll(Expression<Func<TCollection, bool>> filter = null, Action<Pagination> pagination = null);
TCollection ReadSingleOrDefault(Expression<Func<TCollection, bool>> filter);
TCollection ReadFirstOrDefaut(Expression<Func<TCollection, bool>> filter);
TCollection ReadSingle(Expression<Func<TCollection, bool>> filter);
TCollection ReadFirst(Expression<Func<TCollection, bool>> filter);
}
EXAMPLE
public interface ICustomerQueryRepository:IMongoQueryAsyncRepository<Customer>
{
}
public class CustomerQueryRepository : MongoQueryRepository<Customer>, ICustomerQueryRepository
{
public CustomerQueryRepository(IOptions<MongoOption>? option) : base(option, nameof(Customer))
{
}
}
public interface ICustomerCommandRepository:IMongoCreateAsyncRepository<Customer>
{
}
public class CustomerCommandRepository : MongoCommandRepository<Customer>,ICustomerCommandRepository
{
public CustomerCommandRepository(IOptions<MongoOption>? option) : base(option, nameof(Customer))
{
}
}
[Route("api/[controller]")]
[ApiController]
public class CustomersController : ControllerBase
{
private readonly ICustomerQueryRepository _query;
private readonly ICustomerCommandRepository _command;
public CustomersController(ICustomerQueryRepository query, ICustomerCommandRepository command)
{
_query = query;
_command = command;
}
[HttpGet]
public async Task<IActionResult>GetCustomers()
{
var result = await _query.ReadAllAsync();
return Ok(result);
}
[HttpPost]
public async Task<IActionResult>CreateCustomer(Customer customer)
{
var result = await _command.CreateAsync(customer);
return Ok(result);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
- MongoDB.Driver (>= 2.20.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.