Mvp24Hours.Infrastructure.Data.MongoDb 3.1.101

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

// Install Mvp24Hours.Infrastructure.Data.MongoDb as a Cake Tool
#tool nuget:?package=Mvp24Hours.Infrastructure.Data.MongoDb&version=3.1.101

NoSQL Database

A NoSQL (originally referring to "non-SQL" or "non-relational")[1] database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases. Wikipedia

Document Oriented

A document-oriented database, or document store, is a computer program and data storage system designed for storing, retrieving and managing document-oriented information, also known as semi-structured data. Wikipedia

Repository pattern was implemented with search and paging criteria, in addition to unit of work (See Repository). This implementation does not only support late loading of related objects.

Prerequisites (Not Required)

Add a configuration file to the project named "appsettings.json". The file must contain a key with connection data, for example, ConnectionStrings/DataContext as below:

{
  "ConnectionStrings": {
    "DataContext": "connection string"
  },
  "Mvp24Hours": {
    "Persistence": {
      "MaxQtyByQueryPage": 30
    }
  }
}

You will be able to use direct database connection, which is not recommended. Access the ConnectionStrings website and see how to set up the connection with your bank.

MongoDB

Additional configuration for MongoDb registered in "appsettings.json":

{
  "Mvp24Hours": {
    "Persistence": {
      "MongoDb": {
        "EnableTls": false,
        "EnableTransaction": false
      }
    }
  }
}
Installation
/// Package Manager Console >
Install-Package MongoDB.Driver -Version 2.13.2
Install-Package Mvp24Hours.Infrastructure.Data.MongoDb
Configuration
/// Startup.cs

services.AddMvp24HoursMongoDb("mycollection", ConfigurationHelper.GetSettings("ConnectionStrings:DataContext"));
Using Docker

Basic Command

// Command
docker run -d --name mongo -p 27017:27017 mvertes/alpine-mongo

// ConnectionString
mongodb://localhost:27017

Database Command with Password

// Command
docker run --name mongodb -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=user -e MONGO_INITDB_ROOT_PASSWORD=123456 mongo

// ConnectionString
mongodb://user:123456@localhost:27017

Key-Value Oriented

A key–value database, or key–value store, is a data storage paradigm designed for storing, retrieving, and managing associative arrays, and a data structure more commonly known today as a dictionary or hash table. Wikipedia

Redis

In-memory data structure, used as a distributed key-value database, cache and message agent.

Prerequisites (Not Required)

Add a configuration file to the project named "appsettings.json", as below:

{
  "ConnectionStrings": {
    "RedisDbContext": null
  },
  "Mvp24Hours": {
    "Persistence": {
      "Redis": {
        "Enable": true,
        "DefaultExpiration": null,
        "Hosts": [ "localhost:6379" ],
        "InstanceName": null,
        "DefaultDatabase": 0,
        "AbortOnConnectFail": false,
        "AllowAdmin": true,
        "Ssl": false,
        "ConnectTimeout": 6000,
        "ConnectRetry": 2
      }
    }
  }
}

You can use structural configuration or connection string.

Installation
/// Package Manager Console >
Install-Package Mvp24Hours.Infrastructure.Data.Caching.Redis
Configuration
/// Startup.cs

// structural
services.AddMvp24HoursRedisCache();

// connection string
services.AddMvp24HoursRedisCache("ConnectionString");

Usage Example

You can use Redis to record simple values or complex objects, like this:


// reference object
var customer = new Customer
{
    Oid = Guid.NewGuid(),
    Created = DateTime.Now,
    Name = "Test 1",
    Active = true
};

// add simple value
string content = customer.ToSerialize();
CacheHelper.SetString("key", content);

// retrieve simple value
string content = CacheHelper.GetString("key");

// remove simple value
CacheHelper.RemoveString("key");

// add complex value
ObjectCacheHelper.SetObject("key", customer);

// recover complex value
var customer = ObjectCacheHelper.GetObject<Customer>("key");

// remove complex value
CacheHelper.RemoveString("key");

You can use extensions to interact with the IDistributedCache interface in the "Mvp24Hours.Infrastructure.Extensions" namespace.

You can still use the repository concept to restrict the unique types for use.


/// Startup.cs
services.AddScoped<IRepositoryCache<Customer>, RepositoryCache<Customer>>();

// reference object
var customer = new Customer
{
    Oid = Guid.NewGuid(),
    Created = DateTime.Now,
    Name = "Test 1",
    Active = true
};

// add in text format
string content = customer.ToSerialize();
var repo = ServiceProviderHelper.GetService<IRepositoryCache<Customer>>();
repo.SetString("key", content);

// retrieve in text format
var repo = ServiceProviderHelper.GetService<IRepositoryCache<Customer>>();
string content = repo.GetString("key");

// remove
var repo = ServiceProviderHelper.GetService<IRepositoryCache<Customer>>();
repo.Remove(_keyString);

// add complex value
var repo = ServiceProviderHelper.GetService<IRepositoryCache<Customer>>();
repo.Set("key", customer);

// recover complex value
var repo = ServiceProviderHelper.GetService<IRepositoryCache<Customer>>();
var customer = repo.Get("key");

Using Docker
// Command
docker run -d -p 6379:6379 -i -t redis:3.2.5-alpine

// Connect
127.0.0.1:6379

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 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
8.3.261 93 3/26/2024
8.2.102 100 2/9/2024
8.2.101 88 2/7/2024
4.1.191 104 1/19/2024
4.1.181 78 1/19/2024
3.12.262 132 12/26/2023
3.12.261 75 12/26/2023
3.12.221 106 12/22/2023
3.12.151 100 12/17/2023
3.6.221 476 6/22/2022
3.4.111 423 4/11/2022
3.2.241 429 2/24/2022
3.2.171 418 2/17/2022
3.2.151 412 2/15/2022
3.2.142 405 2/14/2022
3.2.141 397 2/14/2022
3.2.21 427 2/2/2022
3.1.243 405 1/25/2022
3.1.242 437 1/24/2022
3.1.241 419 1/24/2022
3.1.221 405 1/22/2022
3.1.201 403 1/20/2022
3.1.101 399 1/10/2022
2.12.291 243 12/29/2021
2.12.102 280 12/10/2021
2.12.101 282 12/10/2021
2.12.71 268 12/7/2021
2.11.241 4,266 11/24/2021