ISM.Database.SQLServer 1.0.5

I.S.M. Database SQLServer

This project is a .NET 10.0 class library that provides a database access layer for SQL Server. It includes methods for connecting to the database, executing queries, and managing transactions. The library is designed to be used in applications that require efficient and reliable data access to SQL Server databases. It supports asynchronous operations and is compatible with the latest features of C# 14.0.

Configuration

To configure the database connection, you can use the following connection string format in your application's configuration file (e.g., appsettings.json):

{
  "ConnectionStrings": {
    "SqlConnection": "Server=your_server;Database=your_database;User Id=your_username;Password=your_password;"
  }
}

[!TIP] The list of additional SQL error numbers to consider transient can be used to specify any custom error codes that your application may encounter and want to treat as transient errors for retry logic.

And to configure SQL Server specific settings, you can add the following section to your configuration file:

{
  "SQLServerSettings": {
    "MigrationAssembly": "YourProject.Migrations",
    "Environment": "Development", // or "Staging" or "Production"
    "CompatibilityLevel": 160, // SQL Server 2022
    "CommandTimeout": 180, // in seconds
    "MaxRetryCount": 5, // number of retry attempts for transient failures
    "MaxRetryDelay": "00:00:10", // maximum delay between retries (10 seconds)
    "ErrorNumbersToAdd": [] // list of additional SQL error numbers to consider transient
  }
}

[!NOTE] The list is available in this Microsoft learn article and can be used to enhance the robustness of your application's database interactions by allowing you to specify additional error codes that should trigger retry logic.

In your application's startup code (e.g., Program.cs), you can retrieve the connection string and SQL Server settings from the configuration and create the SQL Server configuration object as follows:

var connectionString = builder.Configuration.GetConnectionString("SqlConnection")!;
var sqlServerSettings = builder.Services.ConfigureAndGet<SQLServerSettings>(builder.Configuration, nameof(SQLServerSettings));

var sqlServerConfiguration = GetSQLServerConfiguration(builder, connectionString, sqlServerSettings);

Finally in the DbContext configuration it is necessary to add the relevant configuration.

builder.Services.AddDbContext<YourDbContext>(options =>
{
    options.UseSQLServerConfiguration(sqlServerConfiguration);
});

No packages depend on ISM.Database.SQLServer.

Version Downloads Last updated
1.0.30 1 07/05/2026
1.0.29 4 06/15/2026
1.0.27 6 06/04/2026
1.0.26 7 05/24/2026
1.0.25 4 05/22/2026
1.0.24 3 05/20/2026
1.0.23 5 05/19/2026
1.0.22 6 05/17/2026
1.0.21 2 05/16/2026
1.0.20 2 05/14/2026
1.0.19 10 05/09/2026
1.0.17 1 05/08/2026
1.0.16 4 05/08/2026
1.0.15 8 05/03/2026
1.0.11 3 05/02/2026
1.0.6 10 04/30/2026
1.0.5 5 04/29/2026
1.0.1 0 04/26/2026