SyZero.MongoDB
1.1.9
dotnet add package SyZero.MongoDB --version 1.1.9
NuGet\Install-Package SyZero.MongoDB -Version 1.1.9
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="SyZero.MongoDB" Version="1.1.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SyZero.MongoDB" Version="1.1.9" />
<PackageReference Include="SyZero.MongoDB" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SyZero.MongoDB --version 1.1.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SyZero.MongoDB, 1.1.9"
#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.
#:package SyZero.MongoDB@1.1.9
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SyZero.MongoDB&version=1.1.9
#tool nuget:?package=SyZero.MongoDB&version=1.1.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SyZero.MongoDB
SyZero 框架的 MongoDB 集成模块,提供 IMongoContext 和 IRepository<TEntity> 的 MongoDB 实现。
安装
dotnet add package SyZero.MongoDB
配置
{
"MongoDB": {
"DataBase": "syzero",
"UserName": "",
"Password": "",
"Services": [
{
"Host": "localhost",
"Port": 27017
}
]
}
}
UserName和Password可留空,留空时按无认证连接处理。Services至少需要配置一个节点。
注册
using SyZero;
var builder = WebApplication.CreateBuilder(args);
builder.AddSyZero();
builder.Services.AddSyZeroMongoDB();
// 或者从指定配置读取
builder.Services.AddSyZeroMongoDB(builder.Configuration, "MongoDB");
// 或者在默认配置基础上追加覆盖
builder.Services.AddSyZeroMongoDB(options =>
{
options.DataBase = "syzero";
options.Services = new List<MongoServers>
{
new() { Host = "localhost", Port = 27017 }
};
});
使用示例
using SyZero.Domain.Repository;
public class UserService
{
private readonly IRepository<User> _userRepository;
public UserService(IRepository<User> userRepository)
{
_userRepository = userRepository;
}
public Task<User> CreateAsync(User user)
{
return _userRepository.AddAsync(user);
}
public Task<IQueryable<User>> GetActiveUsersAsync()
{
return _userRepository.GetListAsync(x => x.Enabled);
}
}
当前支持能力
Add/AddAsyncAddList/AddListAsyncGetModel/GetModelAsyncGetList/GetListAsyncGetPaged/GetPagedAsyncUpdate/UpdateAsyncDelete/DeleteAsyncCount/CountAsync
当前模块公开接口仍以 IRepository<TEntity> 为准,不提供 IRepository<TEntity, TKey>、聚合管道封装或索引管理 API。
注意事项
- 集合名默认使用实体类型名。
- 实体需要实现
IEntity,主键类型为long。 - 注册成功不代表 MongoDB 连接立即建立,实际访问集合时才会触发网络连接。
许可证
MIT License - 详见 LICENSE
| 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 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. 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- MongoDB.Driver (>= 2.19.0)
- SyZero (>= 1.1.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.9 | 92 | 4/19/2026 |
| 1.1.9-dev.2 | 46 | 4/19/2026 |
| 1.1.9-dev.1 | 52 | 4/17/2026 |
| 1.1.8 | 89 | 4/17/2026 |
| 1.1.6 | 90 | 4/17/2026 |
| 1.1.6-dev.1 | 42 | 4/17/2026 |
| 1.1.5 | 101 | 4/13/2026 |
| 1.1.5-dev.3 | 51 | 4/13/2026 |
| 1.1.5-dev.2 | 63 | 2/11/2026 |
| 1.1.5-dev.1 | 63 | 1/29/2026 |
| 1.1.4 | 124 | 1/2/2026 |
| 1.1.4-dev.2 | 69 | 1/2/2026 |
| 1.1.4-dev.1 | 65 | 12/30/2025 |
| 1.1.3 | 121 | 12/30/2025 |
| 1.1.3-dev.6 | 65 | 12/30/2025 |
| 1.1.3-dev.3 | 131 | 1/19/2024 |
| 1.1.3-dev.2 | 190 | 11/3/2023 |
| 1.1.3-dev.1 | 208 | 3/21/2023 |
| 1.1.2 | 372 | 3/15/2023 |
| 1.0.0 | 101 | 4/17/2026 |
Loading failed