MongoGogo 5.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MongoGogo --version 5.4.0                
NuGet\Install-Package MongoGogo -Version 5.4.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="MongoGogo" Version="5.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MongoGogo --version 5.4.0                
#r "nuget: MongoGogo, 5.4.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.
// Install MongoGogo as a Cake Addin
#addin nuget:?package=MongoGogo&version=5.4.0

// Install MongoGogo as a Cake Tool
#tool nuget:?package=MongoGogo&version=5.4.0                

MongoGogo

Quickly integrate MongoDB into your .NET projects with MongoGogo, a lightweight and powerful ORM designed to elevate your data layer with minimal effort.

Why MongoGogo?

  • Simplify MongoDB Interactions: Utilize generic repository patterns to interact with MongoDB collections using .NET-friendly abstractions.

  • Seamless Integration: Built to fit naturally into the ASP.NET Core framework, supporting dependency injection out of the box.

  • Efficient Data Management: Perform synchronous and asynchronous CRUD operations with ease, thanks to a clear and fluent API.

  • Lambda Expressions: Use the elegance of lambda expressions for more readable and maintainable update and delete operations.

  • Flexible Querying: Leverage the power of LINQ to query MongoDB documents directly in C#.

  • Bulk and Transaction Support: Manage large datasets with bulk operations and maintain data integrity with transaction support.

Quick Start

Implement MongoGogo in your .NET project to enhance your MongoDB operations with minimal configuration.

Installation

dotnet add package MongoGogo

Setup

  1. Define your POCO data models. Use attributes to link them to MongoDB collections.
// Example of a user-defined POCO linked to a MongoDB collection
[MongoCollection(fromDatabase: typeof(MyContext.StudentDb), collectionName: "students")]
public class Student
{
    [BsonId]
    public string Id { get; set; }
    
    public string Name { get; set; }
    public int Age { get; set; }
    // Additional properties can be added as required
}

MyContext is a placeholder for your custom context class, which manages database configurations like connection strings and database names. StudentDb represents the specific configuration for the Student collection within that context.

  1. Implement your custom context class for managing database configurations.
// Define your custom context class inheriting from GoContext
public class MyContext : GoContext<MyContext>
{
    [MongoDatabase]
    public class StudentDb { }

    public MyContext(string connectionString) : base(connectionString)
    {
    }
}

MyContext manages database configurations like connection strings and database names. StudentDb represents the specific configuration for the Student collection within that context.

  1. Configure MongoGogo in your Program.cs:
var builder = WebApplication.CreateBuilder(args);

// Register your custom context class with MongoGogo
builder.Services.AddMongoContext(new MyContext("your-mongodb-connection-string"));

// Continue setting up your application...

Replace MyContext with the name of your context class and "your-mongodb-connection-string" with your actual MongoDB connection string.

  1. For more details on model mapping and attribute configuration, see the setup your models section in our full documentation.

Dependency Injection Setup

Once MongoGogo is configured in your Program.cs, you can inject IGoCollection<T> instances into your classes.

For example, in an ASP.NET Core controller:

public class StudentsController : ControllerBase
{
    private readonly IGoCollection<Student> _studentCollections;

    public StudentsController(IGoCollection<Student> studentCollections)
    {
        _studentCollections = studentCollections;
    }

    // ... CRUD operations using _students
}

Here, StudentsController is an example of a user-created ASP.NET Core controller.

Basic CRUD Operations

MongoGogo simplifies CRUD operations with IGoCollection<T>:

Transactional Support and Bulk Operations

MongoGogo provides robust support for more advanced database operations:

  • Transactional Support: Process multiple operations as a single unit of work to maintain data integrity.
  • Bulk Operations: Handle large numbers of operations in batches for efficiency.

Learn more about bulk operations and transactions section.

Support

For detailed guidelines on configuration and mapping, review our full documentation.

For assistance, reach out at r05221017@gmail.com.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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.

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.0 66 5/20/2024
5.4.1 104 2/5/2024
5.4.0 82 2/2/2024
5.3.0 802 11/16/2023
5.2.2 120 11/3/2023
5.2.1 780 8/7/2023
5.2.0 318 7/24/2023
5.1.2 149 7/21/2023
5.1.1 239 7/4/2023
5.0.1 226 6/28/2023
4.0.0 163 6/19/2023
3.1.0 635 3/17/2023
2.0.1 551 11/18/2022
2.0.0 347 11/18/2022
1.0.3 327 11/10/2022
1.0.2 353 11/9/2022
1.0.1 328 11/9/2022
1.0.0 355 11/9/2022

MongoGogo 5.4.0 Release Notes

Enhanced IGoTransaction with new methods to ensure atomic operations for transactional tasks:
- ReplaceOneAndRetrieve, UpdateOneAndRetrieve, DeleteOneAndRetrieve
- Asynchronous versions: ReplaceOneAndRetrieveAsync, UpdateOneAndRetrieveAsync, DeleteOneAndRetrieveAsync