Sphere10.Framework.Data.MSSQL 3.0.3

dotnet add package Sphere10.Framework.Data.MSSQL --version 3.0.3
                    
NuGet\Install-Package Sphere10.Framework.Data.MSSQL -Version 3.0.3
                    
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="Sphere10.Framework.Data.MSSQL" Version="3.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sphere10.Framework.Data.MSSQL" Version="3.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Sphere10.Framework.Data.MSSQL" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sphere10.Framework.Data.MSSQL --version 3.0.3
                    
#r "nuget: Sphere10.Framework.Data.MSSQL, 3.0.3"
                    
#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.
#:package Sphere10.Framework.Data.MSSQL@3.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sphere10.Framework.Data.MSSQL&version=3.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Sphere10.Framework.Data.MSSQL&version=3.0.3
                    
Install as a Cake Tool

💾 Sphere10.Framework.Data.MSSQL

Microsoft SQL Server implementation for Sphere10.Framework.Data abstraction layer, enabling enterprise-grade database access for large-scale applications with advanced features like linked servers, full-text search, and SQL Agent integration.

Sphere10.Framework.Data.MSSQL brings enterprise SQL Server capabilities to the Sphere10 Framework while maintaining database-agnostic abstraction. Fully compatible with Azure SQL Database, on-premises SQL Server, and SQL Express instances.

📦 Installation

dotnet add package Sphere10.Framework.Data.MSSQL

⚡ 10-Second Example

using Sphere10.Framework.Data;

// Connect to SQL Server (local or remote)
var dac = Tools.MSSQL.Open(
    "Server=.;Database=myapp;Integrated Security=true;");

// Create and query table
dac.ExecuteNonQuery(@"CREATE TABLE Users (
    ID INT PRIMARY KEY IDENTITY(1,1),
    Name NVARCHAR(100) NOT NULL,
    Email NVARCHAR(100)
)");

// Insert record
dac.Insert("Users", new[] {
    new ColumnValue("Name", "Alice"),
    new ColumnValue("Email", "alice@example.com")
});

// Parameterized query
var users = dac.ExecuteQuery(
    "SELECT * FROM Users WHERE Name LIKE @search",
    new ColumnValue("@search", "%Alice%"));

🏗️ Core Concepts

Enterprise Features: Full support for SQL Server features including stored procedures, functions, triggers, and service broker.

Connection Pooling: Advanced connection pool configuration optimized for multi-threaded server applications.

Transaction Isolation Levels: Support for READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, and SERIALIZABLE isolation.

Bulk Operations: Efficient bulk insert/update for large datasets using BULK INSERT and table-valued parameters.

Async Support: Native async operations leveraging .NET async/await patterns for scalability.

🔧 Core Examples

Connection Strings & Server Access

using Sphere10.Framework.Data;

// Local server with integrated security (Windows Authentication)
var localDac = Tools.MSSQL.Open(
    "Server=.;Database=myapp;Integrated Security=true;");

// Named instance
var instanceDac = Tools.MSSQL.Open(
    "Server=.\\SQLEXPRESS;Database=myapp;Integrated Security=true;");

// Remote server with SQL login
var remoteDac = Tools.MSSQL.Open(
    "Server=db.company.com;Database=prod;User Id=sa;Password=P@ssw0rd;");

// Azure SQL Database
var azureDac = Tools.MSSQL.Open(
    "Server=myserver.database.windows.net;Database=mydb;User Id=admin@myserver;Password=P@ssw0rd;");

// Connection pool settings
var pooledDac = Tools.MSSQL.Open(
    "Server=.;Database=myapp;Integrated Security=true;Min Pool Size=10;Max Pool Size=100;");

CRUD Operations with IDENTITY Keys

using Sphere10.Framework.Data;

var dac = Tools.MSSQL.Open(
    "Server=.;Database=shopdb;Integrated Security=true;");

// Create table with IDENTITY primary key
dac.ExecuteNonQuery(@"
    CREATE TABLE Products (
        ProductID INT PRIMARY KEY IDENTITY(1,1),
        Name NVARCHAR(100) NOT NULL,
        Price DECIMAL(10,2),
        StockQuantity INT,
        CategoryID INT
    )");

// Insert records (IDENTITY automatically assigned)
dac.Insert("Products", new[] {
    new ColumnValue("Name", "Laptop"),
    new ColumnValue("Price", 999.99),
    new ColumnValue("StockQuantity", 50),
    new ColumnValue("CategoryID", 1)
});

dac.Insert("Products", new[] {
    new ColumnValue("Name", "Mouse"),
    new ColumnValue("Price", 29.99),
    new ColumnValue("StockQuantity", 200),
    new ColumnValue("CategoryID", 2)
});

// Query with parameters
var expensiveProducts = dac.ExecuteQuery(
    "SELECT * FROM Products WHERE Price > @minPrice ORDER BY Price DESC",
    new ColumnValue("@minPrice", 100.0));

// Update product
dac.Update("Products",
    new[] {
        new ColumnValue("StockQuantity", 45),
        new ColumnValue("Price", 1099.99)
    },
    "WHERE Name = @name",
    new ColumnValue("@name", "Laptop"));

// Delete low-stock items
dac.ExecuteNonQuery(
    "DELETE FROM Products WHERE StockQuantity < @minStock",
    new ColumnValue("@minStock", 10));

Transactions & ACID Compliance

using Sphere10.Framework.Data;

var dac = Tools.MSSQL.Open(
    "Server=.;Database=bankdb;Integrated Security=true;");

// Create account table
dac.ExecuteNonQuery(@"
    CREATE TABLE Accounts (
        AccountID INT PRIMARY KEY IDENTITY(1,1),
        AccountNumber NVARCHAR(20) UNIQUE NOT NULL,
        Balance DECIMAL(18,2) NOT NULL,
        LastModified DATETIME2 DEFAULT GETUTCDATE()
    )");

// Initialize accounts
dac.Insert("Accounts", new[] {
    new ColumnValue("AccountNumber", "ACC001"),
    new ColumnValue("Balance", 10000.00)
});

dac.Insert("Accounts", new[] {
    new ColumnValue("AccountNumber", "ACC002"),
    new ColumnValue("Balance", 5000.00)
});

// Transfer with transaction isolation
using (var scope = dac.BeginTransactionScope()) {
    try {
        // Withdraw from source account
        dac.ExecuteNonQuery(
            "UPDATE Accounts SET Balance = Balance - @amount WHERE AccountID = 1",
            new ColumnValue("@amount", 1000.00));

        // Verify sufficient funds after withdrawal
        var balance = dac.ExecuteScalar<decimal>(
            "SELECT Balance FROM Accounts WHERE AccountID = 1");
        
        if (balance < 0) {
            throw new Exception("Insufficient funds");
        }

        // Deposit to destination account
        dac.ExecuteNonQuery(
            "UPDATE Accounts SET Balance = Balance + @amount WHERE AccountID = 2",
            new ColumnValue("@amount", 1000.00));

        // Both succeed or both rollback
        scope.Commit();
    } catch (Exception ex) {
        Console.WriteLine($"Transaction failed: {ex.Message}");
        // Automatic rollback
    }
}

// Verify final balances
var acc1 = dac.ExecuteScalar<decimal>(
    "SELECT Balance FROM Accounts WHERE AccountID = 1");
var acc2 = dac.ExecuteScalar<decimal>(
    "SELECT Balance FROM Accounts WHERE AccountID = 2");

Console.WriteLine($"Account 1: {acc1}");  // 9000.00
Console.WriteLine($"Account 2: {acc2}");  // 6000.00

Stored Procedure Integration

using Sphere10.Framework.Data;

var dac = Tools.MSSQL.Open(
    "Server=.;Database=appdb;Integrated Security=true;");

// Create stored procedure
dac.ExecuteNonQuery(@"
    CREATE PROCEDURE spGetUsersSince
        @createdAfter DATETIME2
    AS
    BEGIN
        SELECT * FROM Users 
        WHERE CreatedDate >= @createdAfter
        ORDER BY CreatedDate DESC
    END");

// Execute stored procedure with parameters
var recentUsers = dac.ExecuteQuery(
    "EXECUTE spGetUsersSince @createdAfter",
    new ColumnValue("@createdAfter", 
        DateTime.UtcNow.AddDays(-30)));

// Stored procedure for complex operations
dac.ExecuteNonQuery(@"
    CREATE PROCEDURE spProcessMonthlyBilling
    AS
    BEGIN
        DECLARE @processDate DATETIME2 = GETUTCDATE()
        
        UPDATE Invoices 
        SET Status = 'BILLED', BilledDate = @processDate
        WHERE Status = 'PENDING' AND DueDate <= @processDate
        
        INSERT INTO AuditLog (Action, Timestamp)
        VALUES ('Monthly billing processed', @processDate)
    END");

dac.ExecuteNonQuery("EXECUTE spProcessMonthlyBilling");

🏗️ Architecture

MSSQLDatabaseManager: Core implementation of IDataAccessContext for SQL Server operations.

Connection Pool Management: Leverages SQL Server's built-in connection pooling with configurable pool sizes.

SQL Server-Specific Features: Support for hierarchical queries, full-text search, JSON operations, and temporal tables.

Transaction Isolation: Configurable transaction isolation levels for different consistency requirements.

📋 Best Practices

  • Use integrated security (Windows Authentication) for domain-joined applications
  • Configure connection pool size based on expected concurrent connections
  • Leverage stored procedures for complex business logic and performance optimization
  • Use parameterized queries consistently to prevent SQL injection
  • Implement transaction scopes for multi-step operations requiring atomicity
  • Monitor connection pool usage to identify bottlenecks
  • Use IDENTITY(1,1) for auto-incrementing primary keys instead of manual ID management
  • Consider read replicas or read-only secondaries for reporting workloads

📊 Status & Compatibility

  • Framework: .NET 5.0+, .NET Framework 4.7+
  • SQL Server Versions: 2016+, Azure SQL Database, SQL Express
  • Performance: Enterprise-grade, supports thousands of concurrent connections
  • Scalability: Horizontal scaling through multiple connection pools and read replicas

📦 Dependencies

  • Sphere10.Framework.Data: Data abstraction layer
  • Microsoft.Data.SqlClient: Modern SQL Server provider (recommended)
  • System.Data.SqlClient: Legacy provider (.NET Framework)
  • .NET Standard 2.1+: Cross-platform compatibility

📄 License & Author

License: Refer to repository LICENSE
Author: Herman Schoenfeld, Sphere 10 Software (sphere10.com)
Copyright: © 2018-Present Herman Schoenfeld & Sphere 10 Software. All rights reserved.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Sphere10.Framework.Data.MSSQL:

Package Downloads
Sphere10.Framework.Data.NHibernate

NHibernate ORM integration for Sphere10.Framework.Data. Provides configuration and integration helpers for using NHibernate alongside the framework's data abstractions and utilities.

Sphere10.Framework.Windows.Forms.MSSQL

Windows Forms integration for Sphere10.Framework.Data.MSSQL. Provides desktop UI helpers and components intended to work with Sphere10 Framework WinForms and the SQL Server provider for data-driven applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.3 102 1/6/2026
3.0.2 101 1/2/2026
3.0.1 104 1/2/2026
3.0.0 105 1/2/2026