DessCore 3.1.14
dotnet add package DessCore --version 3.1.14
NuGet\Install-Package DessCore -Version 3.1.14
<PackageReference Include="DessCore" Version="3.1.14" />
<PackageVersion Include="DessCore" Version="3.1.14" />
<PackageReference Include="DessCore" />
paket add DessCore --version 3.1.14
#r "nuget: DessCore, 3.1.14"
#:package DessCore@3.1.14
#addin nuget:?package=DessCore&version=3.1.14
#tool nuget:?package=DessCore&version=3.1.14
DessCore
DessCore is a .NET 10 development framework designed for enterprise-grade ASP.NET Core applications. It integrates data access, authentication/authorization, caching, cryptography, and common business-service abstractions into a single, dependency-injection-ready library.
Features
- Data Access — built on FreeSql with multi-database support, automatic schema synchronization, PostgreSQL partitioning, and Snowflake-style ID generation.
- Generic Business Service —
SimpleModelService<T>provides a unified CRUD pipeline with attribute-driven primary/unique/sort keys, FluentValidation integration, soft-delete support, and permission hooks. - Authentication — JWT token issuing, validation, caching, renewal, and JWE encryption backed by
Microsoft.AspNetCore.Authentication.JwtBearer. - Caching — multi-instance Redis connection pools with key prefixes, configurable via
RedisOptions. - Authorization — method-level permission attributes (
AppAuthAttribute) and automatic permission initialization intoAppAuthModel. - Auto-Registration —
[AutoAddScoped]and[AutoAddSingleton]attributes enable assembly-scanning service registration byApplicationID. - Cryptography — AES, RSA, SM2/SM3/SM4, hashing, and digital signature utilities.
- Utilities — Excel helpers, string/entity extensions, date/time utilities, GPS helpers, and more.
Requirements
- .NET 10 SDK or later
- A supported database for FreeSql (e.g., PostgreSQL, MySQL, SQL Server, SQLite)
- Redis (optional, required for token caching and permission caching)
Installation
From NuGet (when published)
dotnet add package DessCore
Local project reference
<ItemGroup>
<ProjectReference Include="..\DessCore\DessCore.csproj" />
</ItemGroup>
Quick Start
1. Configure appsettings.json
{
"ApplicationID": "MyApp",
"DAO": {
"DataType": "PostgreSQL",
"Connection": "Host=localhost;Port=5432;Database=mydb;Username=postgres;Password=postgres",
"AutoSync": true,
"AutoInitAuth": true
},
"Redis": {
"ConnectionString": "localhost:6379,defaultDatabase=0"
},
"JWT": {
"SecurityKey": "your-256-bit-secret-key-here",
"Issuer": "DessCore",
"Audience": "DessCore",
"ExpiresHour": 2
}
}
2. Register services in Program.cs
using DessCore.DI.Builder;
using DessCore.DI.DbServices;
using DessCore.DI.Jwt;
using DessCore.DI.Redis;
var builder = WebApplication.CreateBuilder(args);
// Register Redis, database services, and JWT
builder.Services.AddRedisService(builder.Configuration);
builder.Services.AddSingleton<IDbService, DbServices>();
builder.Services.AddSingleton<IJwt, JwtService>();
// Auto-register attributed services
AutoAddScoped.AddScoped(builder.Configuration, builder.Services);
AutoAddSingleton.AddSingleton(builder.Configuration, builder.Services);
var app = builder.Build();
app.Run();
3. Create a business service
using DessCore.Attributes.DB;
using DessCore.Extend;
using FluentValidation;
public class Product
{
[SimpleModelId]
public long Id { get; set; }
[SimpleModelUnique]
public string Code { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
public class ProductValidator : AbstractValidator<Product>
{
public ProductValidator()
{
RuleFor(p => p.Name).NotEmpty().MaximumLength(200);
}
}
public class ProductService : SimpleModelService<Product>
{
public ProductService(IDbService dbService) : base(dbService) { }
protected override AbstractValidator<Product> Validator => new ProductValidator();
protected override Func<int> GetUtcOffset => () => 8;
protected override Task<bool> AuthValidator(string actionName)
{
// Implement your permission logic here
return Task.FromResult(true);
}
}
4. Use the service in a controller
[ApiController]
[Route("[controller]")]
public class ProductsController : ControllerBase
{
private readonly ProductService _service;
public ProductsController(ProductService service) => _service = service;
[HttpPost("list")]
public async Task<IActionResult> List([FromBody] ProductSearch request)
{
var (rows, total) = await _service.TableList(request);
return Ok(new { data = rows, total });
}
[HttpPost]
public async Task<IActionResult> Create([FromBody] Product product)
{
var created = await _service.Create(product);
return Ok(created);
}
}
Project Structure
DessCore/
├── Attributes/ # Metadata and DI attributes (Auth, Builder, DB, Vue)
├── DI/ # Dependency-injection services (DbServices, Jwt, Redis, ApiJsonResult)
├── Data/ # Domain/config models (AppAuthModel, IClientInfo)
├── Extend/ # Business extensions and SimpleModelService
├── Filter/ # Web API filters
└── Utilities/ # Cryptography utilities (AES, RSA, SM2/SM3/SM4)
Core Dependencies
FreeSqland extensions (JsonMap, Linq, Repository)StackExchange.RedisMicrosoft.AspNetCore.Authentication.JwtBearerFluentValidationBouncyCastle.Cryptography,NSec.Cryptography,Sodium.CoreNewtonsoft.Json,MiniExcel,RabbitMQ.Client,IdGen,IdleBus
For the full dependency list, see DessCore.csproj.
Documentation
- API reference and module guides are maintained under
.qoder/repowiki/zh/content/. - Unit-test examples can be found in TestProject.
Security
DessCore has undergone security hardening for common .NET vulnerabilities, including SQL-injection defenses, ECDH IV handling, and timing-attack mitigations. Transitive dependencies with known vulnerabilities (for example System.Security.Cryptography.Xml) are pinned to patched versions.
License
DessCore is licensed under the MIT License.
Contributing
Contributions are welcome. Please ensure that XML comments and project metadata remain in English, and that new features include relevant unit tests. DessCore
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- BouncyCastle.Cryptography (>= 2.7.0)
- FluentValidation (>= 12.1.1)
- FreeSql (>= 3.5.311)
- FreeSql.Extensions.JsonMap (>= 3.5.311)
- FreeSql.Extensions.Linq (>= 3.5.311)
- FreeSql.Repository (>= 3.5.311)
- IdGen (>= 3.0.7)
- IdleBus (>= 1.5.3)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.11)
- Microsoft.AspNetCore.Mvc (>= 2.3.12)
- MiniExcel (>= 1.45.0)
- Newtonsoft.Json (>= 13.0.4)
- NSec.Cryptography (>= 26.4.0)
- RabbitMQ.Client (>= 7.2.2)
- Sodium.Core (>= 1.4.1)
- StackExchange.Redis (>= 3.1.13)
- System.Security.Cryptography.Xml (>= 10.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Update to .NET 10; UpdateNuGet packages.