NetPro.MongoDb
6.0.5-beta.2
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Core 3.1
This package targets .NET Core 3.1. The package is compatible with this framework or higher.
This is a prerelease version of NetPro.MongoDb.
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 NetPro.MongoDb --version 6.0.5-beta.2
NuGet\Install-Package NetPro.MongoDb -Version 6.0.5-beta.2
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="NetPro.MongoDb" Version="6.0.5-beta.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetPro.MongoDb --version 6.0.5-beta.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NetPro.MongoDb, 6.0.5-beta.2"
#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 NetPro.MongoDb as a Cake Addin #addin nuget:?package=NetPro.MongoDb&version=6.0.5-beta.2&prerelease // Install NetPro.MongoDb as a Cake Tool #tool nuget:?package=NetPro.MongoDb&version=6.0.5-beta.2&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Mongodb使用
对Mongodb的封装,简化使用,支持多库
使用
appsetting.json
"MongoDbOption": {
"ConnectionString": [
{
"Key": "mongo1", //连接串key别名,唯一
"Value": "mongodb://192.168.100.187:27017/netprodemo" //别名key对应的连接串
},
{
"Key": "mongo2", //连接串key别名,唯一
"Value": "mongodb://192.168.100.187:27017/netprodemo2" //别名key对应的连接串
}
]
},
启用服务
没有基于NetPro.Web.Api 的使用场景,必须手动进行初始化,如下:
IConfiguration Configuration;
public void ConfigureServices(IServiceCollection services)
{
//MongoDb 连接配置文件
services.AddMongoDb(Configuration);
}
基于NetPro.Web.Api的使用,只需要添加引用后配置以上appsetting.josn配置MongoDbOption节点即可
使用说明
entity 实体示例
[CollectionName("hu")]
public class Product : Document
{
//[BsonId]
//[BsonRepresentation(BsonType.ObjectId)]
//public string Id { get; set; }
[BsonElement("Name")]
public string Name { get; set; }
public string Category { get; set; }
public string Summary { get; set; }
public string Description { get; set; }
public string ImageFile { get; set; }
public int Price { get; set; }
}
public class MongoDBService : IMongoDBService
{
private readonly IMongoDBMulti _mongoDBMulti;
public MongoDBService(IMongoDBMulti mongoDBMulti)
{
_mongoDBMulti = mongoDBMulti;
}
/// <summary>
/// 查询
/// </summary>
public Product Find(string key = "mongo1")
{
var mongodb = _mongoDBMulti[key];
var filter = Builders<BsonDocument>.Filter;
var product = mongodb.GetCollection<Product>().Find(s => s.Category == "").FirstOrDefault();
return product;
}
}
更新中...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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. |
.NET Core | netcoreapp3.1 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- MongoDbGenericRepository (>= 1.4.8)
- NetPro.Startup (>= 6.0.5-beta.2)
-
net6.0
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- MongoDbGenericRepository (>= 1.4.8)
- NetPro.Startup (>= 6.0.5-beta.2)
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 |
---|---|---|
6.0.16 | 196 | 7/24/2023 |
6.0.15 | 426 | 7/19/2022 |
6.0.14 | 451 | 7/10/2022 |
6.0.13 | 426 | 6/15/2022 |
6.0.12 | 421 | 6/15/2022 |
6.0.11 | 404 | 6/15/2022 |
6.0.10 | 399 | 6/11/2022 |
6.0.9 | 420 | 6/8/2022 |
6.0.8 | 451 | 5/26/2022 |
6.0.8-beta.3 | 144 | 5/24/2022 |
6.0.8-beta.2 | 116 | 5/24/2022 |
6.0.7 | 411 | 5/18/2022 |
6.0.6 | 436 | 4/28/2022 |
6.0.5 | 465 | 3/30/2022 |
6.0.5-beta.20 | 114 | 4/27/2022 |
6.0.5-beta.19 | 122 | 4/25/2022 |
6.0.5-beta.18 | 108 | 4/22/2022 |
6.0.5-beta.17 | 110 | 4/16/2022 |
6.0.5-beta.16 | 192 | 4/8/2022 |
6.0.5-beta.15 | 126 | 4/8/2022 |
6.0.5-beta.14 | 130 | 4/7/2022 |
6.0.5-beta.13 | 131 | 4/7/2022 |
6.0.5-beta.12 | 121 | 4/6/2022 |
6.0.5-beta.11 | 136 | 4/6/2022 |
6.0.5-beta.10 | 138 | 3/31/2022 |
6.0.5-beta.9 | 125 | 3/26/2022 |
6.0.5-beta.8 | 142 | 3/22/2022 |
6.0.5-beta.7 | 126 | 3/21/2022 |
6.0.5-beta.6 | 131 | 3/14/2022 |
6.0.5-beta.5 | 132 | 3/2/2022 |
6.0.5-beta.4 | 135 | 2/22/2022 |
6.0.5-beta.3 | 130 | 2/18/2022 |
6.0.5-beta.2 | 125 | 2/18/2022 |
6.0.5-beta.1 | 130 | 2/16/2022 |
6.0.4 | 477 | 2/10/2022 |
6.0.3 | 448 | 2/9/2022 |
6.0.3-beta.9 | 118 | 2/10/2022 |
6.0.3-beta.7 | 144 | 1/27/2022 |
6.0.3-beta.6 | 148 | 1/19/2022 |
6.0.3-beta.5 | 128 | 1/17/2022 |
6.0.3-beta.4 | 137 | 1/16/2022 |
6.0.3-beta.3 | 133 | 1/14/2022 |
6.0.3-beta.2 | 126 | 1/13/2022 |
6.0.3-beta.1 | 147 | 1/11/2022 |
6.0.2 | 303 | 1/6/2022 |
6.0.1 | 910 | 12/3/2021 |
3.1.10 | 421 | 7/29/2021 |
3.1.9 | 351 | 7/1/2021 |
3.1.8 | 367 | 12/15/2020 |
3.1.6 | 2,943 | 9/16/2020 |
3.1.1 | 1,894 | 6/23/2020 |
3.1.0 | 4,475 | 5/24/2020 |
1.0.1 | 2,007 | 5/4/2020 |
1.0.0 | 1,842 | 4/27/2020 |