LSCode.DatabaseConnectors
3.2.0
dotnet add package LSCode.DatabaseConnectors --version 3.2.0
NuGet\Install-Package LSCode.DatabaseConnectors -Version 3.2.0
<PackageReference Include="LSCode.DatabaseConnectors" Version="3.2.0" />
paket add LSCode.DatabaseConnectors --version 3.2.0
#r "nuget: LSCode.DatabaseConnectors, 3.2.0"
// 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.
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 | Versions 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. |
-
.NETStandard 2.1
- FirebirdSql.Data.FirebirdClient (>= 9.1.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- MongoDB.Driver (>= 2.19.0)
- MySql.Data (>= 8.0.32)
- Npgsql (>= 7.0.2)
- Oracle.ManagedDataAccess.Core (>= 3.21.90)
- StackExchange.Redis (>= 2.6.96)
- System.Data.SqlClient (>= 4.8.5)
- System.Data.SQLite.Core (>= 1.0.117)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Simplified dependency injection for package features;
Updating project dependencies;
Updating the package usage documentation.