Aoxe.Mongo.Client
2025.1.0
dotnet add package Aoxe.Mongo.Client --version 2025.1.0
NuGet\Install-Package Aoxe.Mongo.Client -Version 2025.1.0
<PackageReference Include="Aoxe.Mongo.Client" Version="2025.1.0" />
<PackageVersion Include="Aoxe.Mongo.Client" Version="2025.1.0" />
<PackageReference Include="Aoxe.Mongo.Client" />
paket add Aoxe.Mongo.Client --version 2025.1.0
#r "nuget: Aoxe.Mongo.Client, 2025.1.0"
#:package Aoxe.Mongo.Client@2025.1.0
#addin nuget:?package=Aoxe.Mongo.Client&version=2025.1.0
#tool nuget:?package=Aoxe.Mongo.Client&version=2025.1.0
Aoxe.Mongo
English | 简体中文
Provide an easy way to use Mongo as repository and with UpdateMany / DeleteMany in lambda style.
This project has implemented three packages:
- Aoxe.Mongo.Abstractions - The abstractions of aoxe mongo.
- Aoxe.Mongo.Client - The implements of Aoxe.Mongo.Abstractions.
- Aoxe.Mongo - The service provider extensions for Aoxe.Mongo.Client to simplify the IOC register.
QuickStart
Install the package from NuGet
PM> Install-Package Aoxe.Mongo
Register the AoxeMongoClient into IOC
serviceCollection.AddAoxeMongo("mongodb://localhost:27017", "test");
Inject the IAoxeMongoClient by reference Aoxe.Email.Abstractions.
PM> Install-Package Aoxe.Mongo.Abstractions
public class TestRepository
{
private readonly IAoxeMongoClient _mongoClient;
public TestRepository(IAoxeMongoClient mongoClient)
{
_mongoClient = mongoClient;
}
}
Also you can inject the Lazy<IAoxeMongoClient>.
public class TestRepository
{
private readonly Lazy<IAoxeMongoClient> _mongoClient;
public TestRepository(Lazy<IAoxeMongoClient> mongoClient)
{
_mongoClient = mongoClient;
}
}
If you don't use IOC, you can instantiate AoxeMongoClient directly.
```bash
PM> Install-Package Aoxe.Mongo.Client
var mongoClient = new AoxeMongoClient("mongodb://localhost:27017", "test");
Now we have a Model class like this:
public class TestModel
{
public Guid Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
And then we can use the mongo like a repository:
Add
mongoClient.Add(model);
mongoClient.AddRange(models);
await mongoClient.AddAsync(model);
await mongoClient.AddRangeAsync(models);
Delete
mongoClient.Delete(model);
mongoClient.DeleteMany<TestModel>(m => m.Id == model.Id);
await mongoClient.DeleteAsync(model);
await mongoClient.DeleteManyAsync<TestModel>(m => m.Id == model.Id);
Update
model.Name = "banana";
mongoClient.Update(model);
mongoClient.UpdateMany(() =>
m => m.Id == model.Id,
new TestModel
{
Age = 22,
Name = "pear"
})
await mongoClient.UpdateAsync(model);
await mongoClient.UpdateManyAsync(() =>
m => m.Id == model.Id,
new TestModel
{
Age = 22,
Name = "pear"
})
Query
var query = mongoClient.GetQueryable<TestModel>();
var result = query.FirstOrDefault(p => p.Name == "pear");
var result = query.Where(p => names.Contains(p.Name)).ToList();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Aoxe.Mongo.Abstractions (>= 2025.1.0)
- MongoDB.Driver (>= 3.4.0)
- System.ComponentModel.Annotations (>= 5.0.0)
-
net10.0
- Aoxe.Mongo.Abstractions (>= 2025.1.0)
- MongoDB.Driver (>= 3.4.0)
- System.ComponentModel.Annotations (>= 5.0.0)
-
net8.0
- Aoxe.Mongo.Abstractions (>= 2025.1.0)
- MongoDB.Driver (>= 3.4.0)
- System.ComponentModel.Annotations (>= 5.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Aoxe.Mongo.Client:
Package | Downloads |
---|---|
Aoxe.Mongo
The dependency injection extensions for Aoxe.Mongo.Client. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2025.1.0 | 146 | 7/6/2025 |
2024.6.0 | 188 | 11/5/2024 |
2024.5.12 | 130 | 11/4/2024 |
2024.5.11 | 182 | 10/8/2024 |
2024.5.10 | 180 | 9/9/2024 |
2024.5.9 | 176 | 9/8/2024 |
2024.5.8 | 126 | 9/8/2024 |
2024.5.7 | 240 | 9/6/2024 |
2024.5.6 | 199 | 9/5/2024 |
2024.5.4 | 134 | 9/5/2024 |
2024.5.2 | 151 | 9/5/2024 |
2024.5.0 | 141 | 9/5/2024 |
2024.4.4 | 154 | 9/5/2024 |
2024.4.2 | 163 | 9/5/2024 |
2024.4.0 | 189 | 9/5/2024 |
2024.3.0 | 138 | 9/5/2024 |
2024.2.0 | 187 | 9/4/2024 |
2024.1.0 | 136 | 9/3/2024 |