SafeConnection 1.0.5
See the version list below for details.
dotnet add package SafeConnection --version 1.0.5
NuGet\Install-Package SafeConnection -Version 1.0.5
<PackageReference Include="SafeConnection" Version="1.0.5" />
<PackageVersion Include="SafeConnection" Version="1.0.5" />
<PackageReference Include="SafeConnection" />
paket add SafeConnection --version 1.0.5
#r "nuget: SafeConnection, 1.0.5"
#:package SafeConnection@1.0.5
#addin nuget:?package=SafeConnection&version=1.0.5
#tool nuget:?package=SafeConnection&version=1.0.5
About
SafeConnection is a robust library designed to facilitate secure and efficient database connections. It provides a comprehensive set of features including:
- Secure Connections: Ensures all database connections are secure and encrypted. Additionally, it closes the passed connection explicitly.
- Caching: Implements in-memory caching to reduce database load and improve performance.
- Logging: Integrated logging capabilities to track database operations and errors.
- Compatibility: Supports multiple .NET versions including .NET Standard 3.1 and .NET 6.0.
- Ease of Use: Simple and intuitive API for quick integration into your projects.
This library is ideal for applications that require reliable and secure database interactions with minimal overhead.
Usage Instructions
To use SafeConnection, simply install the package via NuGet and add the following code to your project:
Install the Package: Add the SafeConnection package to your project using NuGet:
dotnet add package SafeConnectionInject the Service: Inject the SafeConnection service into your application as Singleton:
builder.Services.AddSingleton<SafeConnection>(_ => new SafeConnection( appName: builder.Environment.ApplicationName, // It will be used in the logs. environment: builder.Environment.EnvironmentName, // It will be used in the logs. sqlConnectionString: builder.Configuration.GetConnectionString("Your_Sql_log_connectionString"), // Where the logs will be stored. sqlTable: "App_Logs", // The table where the logs will be stored. cacheExpirationMinutes: builder.Configuration.GetValue<int>("CacheExpirationInMinutes") // The expiration time of the cache in minutes. ));Use the Service: Use the SafeConnection service in your application to interact with the database:
public class YourService { private readonly SafeConnection _safeConnection; // Inject SafeConnection service public YourService(SafeConnection safeConnection) { _safeConnection = safeConnection; } // Use SafeConnection to execute SQL queries public async Task<IEnumerable<YourModel>> GetYourData() { return await _safeConnection.QueryAsync<YourModel>("SELECT field1, field2 FROM YourTable", "YourCacheKey"); } }The SQL table structure:
CREATE TABLE App_Logs ( Id int IDENTITY(1,1) NOT NULL, [DateTime] datetime NOT NULL, App varchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, Env varchar(20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, Query varchar(500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, Cached bit NOT NULL, Duration real NOT NULL, [Rows] int NOT NULL, Columns int NOT NULL, Kb int NULL, CONSTRAINT App_Logs_PK PRIMARY KEY (Id) );Enjoy!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Dapper (>= 2.0.90)
- Microsoft.Data.SqlClient (>= 5.2.1)
- Microsoft.Extensions.Caching.Abstractions (>= 3.1.18)
- Microsoft.Extensions.Caching.Memory (>= 3.1.18)
-
net6.0
- Dapper (>= 2.1.35)
- Microsoft.Data.SqlClient (>= 5.2.1)
- Microsoft.Extensions.Caching.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Caching.Memory (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.