![]() |
VOOZH | about |
dotnet add package HMENetCore.MongoDB --version 10.0.9
NuGet\Install-Package HMENetCore.MongoDB -Version 10.0.9
<PackageReference Include="HMENetCore.MongoDB" Version="10.0.9" />
<PackageVersion Include="HMENetCore.MongoDB" Version="10.0.9" />Directory.Packages.props
<PackageReference Include="HMENetCore.MongoDB" />Project file
paket add HMENetCore.MongoDB --version 10.0.9
#r "nuget: HMENetCore.MongoDB, 10.0.9"
#:package HMENetCore.MongoDB@10.0.9
#addin nuget:?package=HMENetCore.MongoDB&version=10.0.9Install as a Cake Addin
#tool nuget:?package=HMENetCore.MongoDB&version=10.0.9Install as a Cake Tool
HMENetCore.MongoDB 是基于官方MongoDB.Driver的增强封装库,专为.NET Core应用提供更便捷的MongoDB集成方案。支持MongoDB 4.0+版本,提供符合领域驱动设计(DDD)的仓储模式实现。
🚀 性能优化
🔐 企业级安全
🧩 开箱即用
dotnet add package HMENetCore.MongoDB
appsettings.json:{
"MongoConfig": {
"ConnectionStrings": ["server1:27017", "server2:27017"],
"DbName": "your_db",
"UserName": "user",
"Password": "pwd",
"UseSsl": true,
"MaxPoolSize": 500
}
}
builder.Services.Configure<MongoConfig>(builder.Configuration.GetSection("MongoConfig"));
builder.Services.AddMongoDBSetup(builder.Configuration.Get<MongoConfig>()!);
[Table("users")]
public class User
{
[BsonId]
public string Id { get; set; }
public string Name { get; set; }
public DateTime CreateTime { get; set; }
}
public class UserRepository : BaseMongoRepository<User>
{
public UserRepository(IMongoContext context) : base(context)
{
}
// 自定义查询方法
public async Task<List<User>> GetActiveUsersAsync()
{
var collection = GetCollection();
return await collection.Find(u => u.CreateTime > DateTime.UtcNow.AddDays(-30))
.ToListAsync();
}
}
public class UserService : BaseMongoService<User>
{
public UserService(IMongoCRUD<User> repository) : base(repository)
{
}
public async Task UpdateUserWithTransactionAsync(string userId, Action<User> update)
{
using var session = await StartSessionAsync();
session.StartTransaction();
try {
var user = await FindByIdAsync(userId);
update(user);
await ReplaceOneAsync(userId, user);
await session.CommitTransactionAsync();
}
catch {
await session.AbortTransactionAsync();
throw;
}
}
}
提供对 MongoContext 的基本操作接口。
仓储层基类,实现了 IMongoCRUD 接口,提供对特定实体的 CRUD 操作。
服务层基类,封装了仓储层的操作,可以在此基础上添加业务逻辑。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.9 | 100 | 5/21/2026 |
| 10.0.8 | 99 | 5/18/2026 |
| 10.0.7 | 159 | 3/17/2026 |
| 10.0.5 | 127 | 2/24/2026 |
| 10.0.3 | 140 | 1/14/2026 |
| 10.0.1 | 505 | 12/10/2025 |
| 10.0.0 | 240 | 11/28/2025 |
| 6.1.10 | 100 | 5/21/2026 |
| 6.1.9 | 98 | 5/18/2026 |
| 6.1.8 | 131 | 3/17/2026 |
| 6.1.6 | 123 | 2/24/2026 |
| 6.1.5 | 149 | 1/14/2026 |
| 6.1.2 | 493 | 12/10/2025 |
| 6.1.0 | 246 | 11/24/2025 |
| 6.0.52 | 263 | 10/20/2025 |
| 6.0.51 | 235 | 9/23/2025 |
| 6.0.50 | 392 | 9/18/2025 |