Aoxe.Mongo.Abstractions 2024.4.1

dotnet add package Aoxe.Mongo.Abstractions --version 2024.4.1                
NuGet\Install-Package Aoxe.Mongo.Abstractions -Version 2024.4.1                
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="Aoxe.Mongo.Abstractions" Version="2024.4.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aoxe.Mongo.Abstractions --version 2024.4.1                
#r "nuget: Aoxe.Mongo.Abstractions, 2024.4.1"                
#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 Aoxe.Mongo.Abstractions as a Cake Addin
#addin nuget:?package=Aoxe.Mongo.Abstractions&version=2024.4.1

// Install Aoxe.Mongo.Abstractions as a Cake Tool
#tool nuget:?package=Aoxe.Mongo.Abstractions&version=2024.4.1                

Aoxe.Mongo

English | 简体中文

Provide an easy way to use Mongo as repository and with UpdateMany / DeleteMany in lambda style.

This project has implemented three packages:

  • Aoxe.Mongo.Abstractions - The abstractions of aoxe mongo.
  • Aoxe.Mongo.Client - The implements of Aoxe.Mongo.Abstractions.
  • Aoxe.Mongo - The service providere extensions for Aoxe.Mongo.Client to simplify the IOC register.

QuickStart

Install the package from NuGet

PM> Install-Package Aoxe.Mongo

Register the AoxeMongoClient into IOC

serviceCollection.AddAoxeMongo("mongodb://localhost:27017", "test");

Inject the IAoxeMongoClient by reference Aoxe.Email.Abstractions.

PM> Install-Package Aoxe.Mongo.Abstractions
public class TestRepository
{
    private readonly IAoxeMongoClient _mongoClient;

    public TestRepository(IAoxeMongoClient mongoClient)
    {
        _mongoClient = mongoClient;
    }
}

If you don't use IOC, you can instantiate AoxeMongoClient directly.

PM> Install-Package Aoxe.Mongo.Client
var mongoClient = new AoxeMongoClient("mongodb://localhost:27017", "test");

Now we have a Model class like this:

public class TestModel
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public int Age { get; set; }
}

And then we can use the mongo like a repository:

Add

mongoClient.Add(model);
mongoClient.AddRange(models);

await mongoClient.AddAsync(model);
await mongoClient.AddRangeAsync(models);

Delete

mongoClient.Delete(model);
mongoClient.DeleteMany<TestModel>(m => m.Id == model.Id);

await mongoClient.DeleteAsync(model);
await mongoClient.DeleteManyAsync<TestModel>(m => m.Id == model.Id);

Update

model.Name = "banana";
mongoClient.Update(model);
mongoClient.UpdateMany(() =>
    m => m.Id == model.Id,
    new TestModel
    {
        Age = 22,
        Name = "pear"
    })

await mongoClient.UpdateAsync(model);
await mongoClient.UpdateManyAsync(() =>
    m => m.Id == model.Id,
    new TestModel
    {
        Age = 22,
        Name = "pear"
    })

Query

var query = mongoClient.GetQueryable<TestModel>();
var result = query.FirstOrDefault(p => p.Name == "pear");
var result = query.Where(p => names.Contains(p.Name)).ToList();
Product 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Aoxe.Mongo.Abstractions:

Package Downloads
Aoxe.Mongo.Client

Mongo repository.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2024.4.1 575 9/6/2024
2024.4.0 581 9/3/2024
2024.3.0 103 9/3/2024
2024.2.0 111 9/3/2024
2024.1.0 186 6/13/2024