AnointedAutomation.Objects.Mongo
0.0.2
dotnet add package AnointedAutomation.Objects.Mongo --version 0.0.2
NuGet\Install-Package AnointedAutomation.Objects.Mongo -Version 0.0.2
<PackageReference Include="AnointedAutomation.Objects.Mongo" Version="0.0.2" />
<PackageVersion Include="AnointedAutomation.Objects.Mongo" Version="0.0.2" />
<PackageReference Include="AnointedAutomation.Objects.Mongo" />
paket add AnointedAutomation.Objects.Mongo --version 0.0.2
#r "nuget: AnointedAutomation.Objects.Mongo, 0.0.2"
#:package AnointedAutomation.Objects.Mongo@0.0.2
#addin nuget:?package=AnointedAutomation.Objects.Mongo&version=0.0.2
#tool nuget:?package=AnointedAutomation.Objects.Mongo&version=0.0.2
AnointedAutomation.Objects.Mongo
A .NET library providing MongoDB-specific data models with BSON serialization attributes, extending the base AnointedAutomation.Objects classes.
Overview
AnointedAutomation.Objects.Mongo provides MongoDB-specific versions of the core data models from AnointedAutomation.Objects. These classes add BSON attributes and MongoDB-specific serialization support while maintaining full compatibility with the base objects through inheritance.
Installation
Install via NuGet:
dotnet add package AnointedAutomation.Objects.Mongo
Features
- MongoDB-Specific Models: Classes with
[BsonId]and[BsonIgnoreExtraElements]attributes - BSON Serialization: Native MongoDB BSON serialization support
- JObject Serialization: Custom serializer for Newtonsoft.Json JObjects to BSON
- Inheritance Pattern: Extends base Objects classes, allowing seamless casting
- Clean Separation: Keeps MongoDB dependencies separate from base models
Key Differences from AnointedAutomation.Objects
- Adds
[BsonId]attribute to ID properties - Adds
[BsonIgnoreExtraElements]for flexible schema evolution - Includes JObjectSerializer for JObject to BSON conversion
- Designed specifically for MongoDB persistence
Core Models
Account Namespace
MongoUser- MongoDB-specific user with[BsonId]on UserIdMongoProfile- MongoDB-specific profile with JObject serialization
Utilities
JObjectSerializer- Custom serializer for JObject to BSON conversion
Usage Example
using AnointedAutomation.Objects.Mongo.Account;
using MongoDB.Driver;
// Create a MongoDB-specific user
var mongoUser = new MongoUser
{
UserId = Guid.NewGuid().ToString(),
Email = "user@example.com",
Username = "johndoe",
createdDate = DateTime.UtcNow
};
// The MongoUser can be stored directly in MongoDB
// The UserId property is automatically used as the _id field
var collection = database.GetCollection<MongoUser>("users");
await collection.InsertOneAsync(mongoUser);
// Can also be used as base User type
User baseUser = mongoUser;
Dependencies
- .NET 8.0
- MongoDB.Bson (3.6.0)
- Newtonsoft.Json (13.0.4)
- AnointedAutomation.Objects (project reference)
License
Copyright © 2023 Anointed Automation, LLC. All rights reserved.
Author
Created by Alexander Fields
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
-
net8.0
- AnointedAutomation.Objects (>= 0.0.20)
- MongoDB.Bson (>= 3.6.0)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.