AsNet.Shared.Data 2.3.0.1

dotnet add package AsNet.Shared.Data --version 2.3.0.1
                    
NuGet\Install-Package AsNet.Shared.Data -Version 2.3.0.1
                    
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="AsNet.Shared.Data" Version="2.3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AsNet.Shared.Data" Version="2.3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AsNet.Shared.Data" />
                    
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 AsNet.Shared.Data --version 2.3.0.1
                    
#r "nuget: AsNet.Shared.Data, 2.3.0.1"
                    
#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 AsNet.Shared.Data@2.3.0.1
                    
#: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=AsNet.Shared.Data&version=2.3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=AsNet.Shared.Data&version=2.3.0.1
                    
Install as a Cake Tool

AsNet.Shared.Data

Enterprise‑grade, multi‑tenant data infrastructure library for .NET that provides dynamic connection string resolution, secure integration with AsNetSecurity and IdentityServer, and a complete generic data access framework built on Entity Framework Core.


Overview

AsNet.Shared.Data is a shared data infrastructure framework designed for enterprise and multi‑tenant applications.
It centralizes connection string resolution, security‑aware data access, and provides generic, reusable data access components for both Entity‑first and DTO‑first architectures.

The library integrates directly with AsNetSecurity (V1 and V2) and IdentityServer (OAuth2 / OpenID Connect) to securely resolve tenant‑specific connection strings and initialize safe, isolated DbContext instances per tenant.


Key Features

  • Multi‑tenant architecture with dynamic connection string resolution.
  • ✅ Integration with AsNetSecurity V1 / V2.
  • ✅ Secure access using OAuth2 / IdentityServer.
  • ✅ Centralized tenant initialization via BaseApplication.
  • ✅ Generic Entity‑first repositories (queries & commands).
  • ✅ Generic DTO‑first repositories using AutoMapper.
  • ✅ Support for streaming queries with IAsyncEnumerable<T>.
  • ✅ Rich stored procedure support (OUTPUT & RETURN values).
  • ✅ Transaction management.
  • ✅ Standardized result contracts (DmlResult, BResult).
  • ✅ Built‑in auditing support.
  • ✅ Contextual logging by Tenant, Entity, DTO, and Host.
  • ✅ Configuration‑driven behavior via appsettings.json.
  • ✅ Multi‑framework support.

Supported Frameworks

  • .NET Standard 2.1
  • .NET 8.0
  • .NET 9.0
  • .NET 10.0

Architecture Overview

The package is structured in three clear layers:

1️⃣ Infrastructure Layer

  • Dynamic tenant connection resolution
  • Security integration
  • DbContext initialization

Core components:

  • ApplicationSettings
  • ConnectionStringService
  • SecuritySourceEnum
  • BaseApplication<TDbContext>

2️⃣ Persistence Layer (Entity‑First)

Generic repositories built directly on Entity Framework Core.

Queries
  • GenericQueries<TEntity, TContext>

Supports:

  • Filters, ordering, includes
  • Projections
  • Streaming queries
  • Raw SQL & stored procedures
  • StandardList builders
Commands
  • GenericCommands<TEntity, TContext>
  • GenericCommandsDml<TEntity, TContext>

Supports:

  • CRUD & bulk operations
  • Transactions
  • Stored procedures
  • Typed primary key retrieval
  • DmlResult standardized responses

3️⃣ Application Layer (DTO‑First)

Designed for Application Services and APIs.

Queries
  • GenericQueriesB<TDto, TEntity, TContext>
  • GenericQueriesBResult<TDto, TEntity, TContext>

Features:

  • DTO‑first querying
  • Expression mapping (AutoMapper)
  • Streaming
  • BResult standardized responses
Commands
  • GenericCommandsB<TDto, TEntity, TContext>
  • GenericCommandsBResult<TDto, TEntity, TContext>

Features:

  • DTO‑first commands
  • Validation & existence checks
  • Optional auditing (IAuditable<TAudit>)
  • Transaction support
  • BResult for API‑friendly responses

Security & Multi‑Tenant Support

Supported Connection Sources

Connection strings can be resolved from:

  • AppSettings
  • AsNetSecurity V1
  • AsNetSecurity V2

Selection is controlled via SecuritySourceEnum and configuration defaults.


Required Configuration

"AsNet": {
  "Security": {
    "ApplicationSettings": {
      "CommandTimeout": 301,
      "ConnectionProviderName": "Microsoft.Data.SqlClient",
      "ApplicationId": "<application-id>",
      "ApplicationName": "<application-name>",
      "ApplicationSalt": "<application-salt>",
      "ConnectionType": "Production",
      "SecurityWebApi": "https://your-security-api",
      "DefaultLocalConnectionName": "DefaultConnection",
      "DBContextLogger": false,
      "DefaultSecuritySource": "AppSettings"
    },
    "IdentityServerSettings": {
      "Address": "https://your-identityserver",
      "ClientId": "<client-id>",
      "ClientSecret": "<client-secret>",
      "Scope": "<scope>"
    }
  }
}
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 is compatible.  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 is compatible.  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

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
2.3.0.1 36 4/8/2026
2.3.0 86 4/6/2026
2.2.2 89 3/26/2026
2.2.1.1 118 2/9/2026
2.2.1 129 1/14/2026
2.2.0 112 1/13/2026
2.1.1.6 248 6/30/2025
2.1.1.5 232 1/6/2025
2.1.1.4 205 12/9/2024
2.1.1.3 216 12/9/2024 2.1.1.3 is deprecated because it has critical bugs.
2.1.1.2 238 11/11/2024
2.1.1.1 243 9/6/2024
2.1.1 238 6/9/2024
2.1.0.8 248 5/29/2024
2.1.0.7 277 4/1/2024
2.1.0.6 232 3/30/2024
2.1.0.5 274 9/29/2023
2.1.0.4 213 9/28/2023
2.1.0.3 251 9/2/2023
2.1.0.2 289 6/15/2023
Loading failed

• Designed for .NET 8.0, .NET 9.0, and .NET 10.0.
• Introduces a complete multi‑tenant data infrastructure built on Entity Framework Core.
• Adds dynamic connection string resolution per tenant with AsNetSecurity V1 and V2 integration.
• Includes generic Entity‑first repositories for queries and commands.
• Adds DTO‑first repositories using AutoMapper for application and API layers.
• Supports streaming data access using IAsyncEnumerable<T>.
• Includes standardized result contracts (DmlResult and BResult).
• Adds built‑in support for stored procedures with OUTPUT and RETURN values.
• Provides transaction management and optional auditing support.
• Improves contextual logging with tenant, entity, DTO, and host metadata.