MongoDB.MvcCore 1.0.9

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

// Install MongoDB.MvcCore as a Cake Tool
#tool nuget:?package=MongoDB.MvcCore&version=1.0.9                

MongoDB.MvcCore

Serialization Extensions to MvcCore for using MongoDB

The MongoDB.MvcCore contains extensions to the MongDB framework where Json strings can be used as input and output can be deserialized to Json.

The deserializer can also be used as a pretty-print formatter. On console apps the pretty-print feature can ben colorized. However this is no strict Json.

pretty print colored

The non-colorized Json output is 'valid' Json

pretty print

The serializer can also be used in an MvcCore project which enables seemless integration of json output from a controller to a client.

using MongoDB.Driver;
using MongoDB.MvcCore;

var services = builder.Services;

var mongoclient = new MongoClient("mongodb://127.0.0.1:27017");

services.AddSingleton<IMongoClient>(mongoclient);

services
    .AddMvcCore()
    .AddBsonJsonConverters(); // Serialization in API controller
public class MongoController : ControllerBase
{
	private readonly IMongoClient mongo;
	public MongoController(IMongoClient mongoClient)
	{
		this.mongo = mongoClient;
	}

	[HttpGet]
	[Route("~/api/ShowCollection")]
	public async Task<IActionResult> ShowCollection()
	{
		var List = await mongo
			.GetDatabase("demo")
			.GetCollection("collection1")
			.Find("{}")
			.ToListAsync();

		return Ok(new
		{
			List
		});
	}
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
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
1.0.9 379 12/5/2022