Tools.Net.Mongo.Core
2.0.0
See the version list below for details.
dotnet add package Tools.Net.Mongo.Core --version 2.0.0
NuGet\Install-Package Tools.Net.Mongo.Core -Version 2.0.0
<PackageReference Include="Tools.Net.Mongo.Core" Version="2.0.0" />
<PackageVersion Include="Tools.Net.Mongo.Core" Version="2.0.0" />
<PackageReference Include="Tools.Net.Mongo.Core" />
paket add Tools.Net.Mongo.Core --version 2.0.0
#r "nuget: Tools.Net.Mongo.Core, 2.0.0"
#addin nuget:?package=Tools.Net.Mongo.Core&version=2.0.0
#tool nuget:?package=Tools.Net.Mongo.Core&version=2.0.0
Tools.NET Mongo Core
Overview
A core library for managing MongoDB databases from a .NET application
Getting Started
To get started create a Collection class that inherits the MongoDbCollection
class. A Collection class is used to manage the appication's interactions with a single MongoDB collection in a database.
MongoDbCollection
is a generic, abstract class that contains common MongoDB CRUD operations. The model used for TEntityType
defines the document structure for the given MongoDB collection. The data model should use MongoDB Serialization Attributes to define the MongoDB data type and behaviors of each model property. MongoDbCollection
can be used with new or existing MongoDB databases.
By default, the MongoDb collection connect to a MongoDbCollection
class will be the camel cased name of the class passed in as the TEntityType
. For the example below, the MongoDB collection create will be pet. To override the default naming, override the CollectionName
property.
public class Pet
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
[BsonIgnoreIfDefault]
public string Type { get; set; }
[BsonIgnoreIfDefault]
public string Breed { get; set; }
[BsonRequired]
public string Name { get; set; }
[BsonRepresentation(BsonType.Int32)]
public int Age { get; set; }
}
public class PetCollection : MongoDbCollection<Pet>
{
public PetCollection(IMongoDbContext context) : base(context)
{
}
}
A MongoDbCollection
requires an instance of IMongoDbContext
to be passed into the constructor. A MongoDB context class represents the connection to a single MongoDB database. To create an instance of IMongoDbContext
use the MongoDbContextBuilder
class.
var petDatabase = MongoDbContextBuilder.Build("mongodb://localhost:27017/petDatabase");
var petCollection = new PetCollection(petDatabase);
Once the collection is created, any of the CRUD operation can be called from the collection instance.
var insertResult = petCollection.Insert(pet);
To create custom queries, use the Collection
property to access the underlying MongoDB driver MongoCollection class.
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. |
-
.NETStandard 2.1
- MongoDB.Driver (>= 2.9.1)
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 |
---|---|---|
3.4.0 | 150 | 1/4/2025 |
3.3.0 | 303 | 10/7/2023 |
3.2.0 | 184 | 5/13/2023 |
3.1.0 | 608 | 4/29/2022 |
3.0.0 | 618 | 4/14/2022 |
2.0.0 | 689 | 1/22/2022 |
2.0.0-rc | 455 | 12/24/2019 |
2.0.0-beta | 447 | 12/23/2019 |
1.0.0 | 648 | 9/13/2019 |
1.0.0-alpha | 491 | 8/31/2019 |