SyZero.MongoDB
10.0.0
dotnet add package SyZero.MongoDB --version 10.0.0
NuGet\Install-Package SyZero.MongoDB -Version 10.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="SyZero.MongoDB" Version="10.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SyZero.MongoDB" Version="10.0.0" />
<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 10.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SyZero.MongoDB, 10.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.
#:package SyZero.MongoDB@10.0.0
#: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=10.0.0
#tool nuget:?package=SyZero.MongoDB&version=10.0.0
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.Configuration);
// 或者从指定配置读取
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 | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Castle.Core (>= 5.2.1)
- Dynamitey (>= 2.0.10.189)
- ImpromptuInterface (>= 7.0.1)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Caching.Memory (>= 10.0.13)
- Microsoft.Extensions.Configuration (>= 10.0.13)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.13)
- Microsoft.Extensions.Configuration.Json (>= 10.0.13)
- Microsoft.Extensions.DependencyInjection (>= 10.0.13)
- Microsoft.Extensions.DependencyModel (>= 10.0.13)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.13)
- MongoDB.Driver (>= 3.12.0)
- Refit (>= 8.0.0)
- SharpCompress (>= 0.50.7)
- Snappier (>= 1.3.1)
- Snowflake.Core (>= 2.0.0)
- System.Linq.Dynamic.Core (>= 1.6.6)
- SyZero.Core (>= 10.0.0)
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 |
|---|---|---|
| 10.0.0 | 91 | 10/23/2026 |
| 9.1.0 | 86 | 10/22/2026 |
| 1.2.0 | 86 | 10/22/2026 |
| 1.2.0-dev.1 | 50 | 10/22/2026 |
| 1.1.9 | 147 | 4/19/2026 |
| 1.1.9-dev.2 | 82 | 4/19/2026 |
| 1.1.9-dev.1 | 87 | 4/17/2026 |
| 1.1.8 | 137 | 4/17/2026 |
| 1.1.6 | 135 | 4/17/2026 |
| 1.1.6-dev.1 | 69 | 4/17/2026 |
| 1.1.5 | 148 | 4/13/2026 |
| 1.1.5-dev.3 | 83 | 4/13/2026 |
| 1.1.5-dev.2 | 95 | 2/11/2026 |
| 1.1.5-dev.1 | 94 | 1/29/2026 |
| 1.1.4 | 167 | 1/2/2026 |
| 1.1.4-dev.2 | 104 | 1/2/2026 |
| 1.1.4-dev.1 | 97 | 12/30/2025 |
| 1.1.3 | 164 | 12/30/2025 |
| 1.1.3-dev.6 | 99 | 12/30/2025 |
| 1.0.0 | 149 | 4/17/2026 |
Loading failed