LSCode.DatabaseConnectors 3.2.0

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

// Install LSCode.DatabaseConnectors as a Cake Tool
#tool nuget:?package=LSCode.DatabaseConnectors&version=3.2.0

LSCode.DatabaseConnectors

Application:

Offers codes to facilitate connections to databases in LSCode projects.

NuGet version (LSCode.DatabaseConnectors)


Frameworks:

  • .Net Standard 2.1

Currently supported:

  • Relational databases

    • Firebird
    • MySQL
    • Oracle
    • PostgreSQL
    • SQLite
    • SQL Server
  • Non-relational databases

    • MongoDB
    • Redis

Dependencies:

  • FirebirdSql.Data.FirebirdClient
  • Microsoft.Extensions.DependencyInjection.Abstractions
  • MongoDB.Driver
  • MySql.Data
  • Npgsql
  • Oracle.ManagedDataAccess.Core
  • StackExchange.Redis
  • System.Data.SqlClient
  • System.Data.SQLite.Core

Dependencies (Test projects):

  • Microsoft.NET.Test.Sdk
  • NUnit
  • NUnit3TestAdapter
  • NUnit.Analyzers
  • coverlet.collector

How to install:

  • Click on the following link and see here some ways to install: click here.

How to use Firebird:

First install the package, for example:

<PackageReference Include="LSCode.DatabaseConnectors" Version="x.x.x" />

In the file where the services used in the application are added (Startup.cs, Program.cs or others), you must import the following namespaces:

using LSCode.DatabaseConnectors.DataContexts.Enums;
using LSCode.DatabaseConnectors.DataContexts.Extensions;

Then add the following line to register the service:

services.AddDataContext(DatabaseManagementSystem.Firebird, "connectionString");

//or

builder.Services.AddDataContext(DatabaseManagementSystem.Firebird, "connectionString");

In the file that you want to use the database connection context, you must import the following namespace:

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

The context contains a property called Connection. As its name implies, this property contains the connection to the configured database.

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

namespace MyNamespace
{
  public class MyClass
  {
    private readonly IFirebirdContext _context;

    public MyClass(IFirebirdContext context) => _context = context;

    public Task Delete(long id) => ... _context.Connection ...;
  }
}

How to use MongoDB:

First install the package, for example:

<PackageReference Include="LSCode.DatabaseConnectors" Version="x.x.x" />

In the file where the services used in the application are added (Startup.cs, Program.cs or others), you must import the following namespaces:

using LSCode.DatabaseConnectors.DataContexts.Enums;
using LSCode.DatabaseConnectors.DataContexts.Extensions;

Then add the following line to register the service:

services.AddDataContext(DatabaseManagementSystem.MongoDB, "connectionString", "databaseName");

//or

builder.Services.AddDataContext(DatabaseManagementSystem.MongoDB, "connectionString", "databaseName");

In the file that you want to use the database connection context, you must import the following namespace:

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

The context contains a property called Connection. As its name implies, this property contains the connection to the configured database.

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

namespace MyNamespace
{
  public class MyClass
  {
    private readonly IMongoDBContext _context;

    public MyClass(IMongoDBContext context) => _context = context;

    public Task Delete(long id) => ... _context.Connection ...;
  }
}

How to use MySQL:

First install the package, for example:

<PackageReference Include="LSCode.DatabaseConnectors" Version="x.x.x" />

In the file where the services used in the application are added (Startup.cs, Program.cs or others), you must import the following namespaces:

using LSCode.DatabaseConnectors.DataContexts.Enums;
using LSCode.DatabaseConnectors.DataContexts.Extensions;

Then add the following line to register the service:

services.AddDataContext(DatabaseManagementSystem.MySQL, "connectionString");

//or

builder.Services.AddDataContext(DatabaseManagementSystem.MySQL, "connectionString");

In the file that you want to use the database connection context, you must import the following namespace:

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

The context contains a property called Connection. As its name implies, this property contains the connection to the configured database.

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

namespace MyNamespace
{
  public class MyClass
  {
    private readonly IMySQLContext _context;

    public MyClass(IMySQLContext context) => _context = context;

    public Task Delete(long id) => ... _context.Connection ...;
  }
}

How to use Oracle:

First install the package, for example:

<PackageReference Include="LSCode.DatabaseConnectors" Version="x.x.x" />

In the file where the services used in the application are added (Startup.cs, Program.cs or others), you must import the following namespaces:

using LSCode.DatabaseConnectors.DataContexts.Enums;
using LSCode.DatabaseConnectors.DataContexts.Extensions;

Then add the following line to register the service:

services.AddDataContext(DatabaseManagementSystem.Oracle, "connectionString");

//or

builder.Services.AddDataContext(DatabaseManagementSystem.Oracle, "connectionString");

In the file that you want to use the database connection context, you must import the following namespace:

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

The context contains a property called Connection. As its name implies, this property contains the connection to the configured database.

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

namespace MyNamespace
{
  public class MyClass
  {
    private readonly IOracleContext _context;

    public MyClass(IOracleContext context) => _context = context;

    public Task Delete(long id) => ... _context.Connection ...;
  }
}

How to use PostgreSQL:

First install the package, for example:

<PackageReference Include="LSCode.DatabaseConnectors" Version="x.x.x" />

In the file where the services used in the application are added (Startup.cs, Program.cs or others), you must import the following namespaces:

using LSCode.DatabaseConnectors.DataContexts.Enums;
using LSCode.DatabaseConnectors.DataContexts.Extensions;

Then add the following line to register the service:

services.AddDataContext(DatabaseManagementSystem.PostgreSQL, "connectionString");

//or

builder.Services.AddDataContext(DatabaseManagementSystem.PostgreSQL, "connectionString");

In the file that you want to use the database connection context, you must import the following namespace:

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

The context contains a property called Connection. As its name implies, this property contains the connection to the configured database.

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

namespace MyNamespace
{
  public class MyClass
  {
    private readonly IPostgreSQLContext _context;

    public MyClass(IPostgreSQLContext context) => _context = context;

    public Task Delete(long id) => ... _context.Connection ...;
  }
}

How to use Redis:

First install the package, for example:

<PackageReference Include="LSCode.DatabaseConnectors" Version="x.x.x" />

In the file where the services used in the application are added (Startup.cs, Program.cs or others), you must import the following namespaces:

using LSCode.DatabaseConnectors.DataContexts.Enums;
using LSCode.DatabaseConnectors.DataContexts.Extensions;

Then add the following line to register the service:

services.AddDataContext(DatabaseManagementSystem.Redis, "connectionString");

//or

builder.Services.AddDataContext(DatabaseManagementSystem.Redis, "connectionString");

In the file that you want to use the database connection context, you must import the following namespace:

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

The context contains a property called Connection. As its name implies, this property contains the connection to the configured database.

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

namespace MyNamespace
{
  public class MyClass
  {
    private readonly IRedisContext _context;

    public MyClass(IRedisContext context) => _context = context;

    public Task Delete(long id) => ... _context.Connection ...;
  }
}

How to use SQLite:

First install the package, for example:

<PackageReference Include="LSCode.DatabaseConnectors" Version="x.x.x" />

In the file where the services used in the application are added (Startup.cs, Program.cs or others), you must import the following namespaces:

using LSCode.DatabaseConnectors.DataContexts.Enums;
using LSCode.DatabaseConnectors.DataContexts.Extensions;

Then add the following line to register the service:

services.AddDataContext(DatabaseManagementSystem.SQLite, "connectionString");

//or

builder.Services.AddDataContext(DatabaseManagementSystem.SQLite, "connectionString");

In the file that you want to use the database connection context, you must import the following namespace:

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

The context contains a property called Connection. As its name implies, this property contains the connection to the configured database.

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

namespace MyNamespace
{
  public class MyClass
  {
    private readonly ISQLiteContext _context;

    public MyClass(ISQLiteContext context) => _context = context;

    public Task Delete(long id) => ... _context.Connection ...;
  }
}

How to use SQLServer:

First install the package, for example:

<PackageReference Include="LSCode.DatabaseConnectors" Version="x.x.x" />

In the file where the services used in the application are added (Startup.cs, Program.cs or others), you must import the following namespaces:

using LSCode.DatabaseConnectors.DataContexts.Enums;
using LSCode.DatabaseConnectors.DataContexts.Extensions;

Then add the following line to register the service:

services.AddDataContext(DatabaseManagementSystem.SQLServer, "connectionString");

//or

builder.Services.AddDataContext(DatabaseManagementSystem.SQLServer, "connectionString");

In the file that you want to use the database connection context, you must import the following namespace:

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

The context contains a property called Connection. As its name implies, this property contains the connection to the configured database.

using LSCode.DatabaseConnectors.DataContexts.Interfaces;

namespace MyNamespace
{
  public class MyClass
  {
    private readonly ISQLServerContext _context;

    public MyClass(ISQLServerContext context) => _context = context;

    public Task Delete(long id) => ... _context.Connection ...;
  }
}

Connection string examples:

Database Connection String
Firebird Server=localhost; Database=C:\database.FDB; User=SYSDBA; Password=masterkey;
MongoDB mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass%20Community&ssl=false
MySQL SERVER=localhost; DATABASE=mysql; UID=root; PASSWORD=root;
Oracle User ID=SYSTEM;Password=root;Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = xe)));Pooling=true;Connection Lifetime=300;Max Pool Size=20;
PostgreSQL Server=localhost;Port=5432;Database=LSCode.DatabaseConnectors.Test;User Id=postgres;Password=root;
Redis localhost
SQLite Data Source=C:\database.sqlite;Version=3;
SQL Server Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=PC\SQLEXPRESS;
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.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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

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
3.2.0 236 2/28/2023
3.1.0 252 1/18/2023
3.0.6 351 8/30/2022
3.0.5 363 8/30/2022

Simplified dependency injection for package features;
Updating project dependencies;
Updating the package usage documentation.