Acontplus.Core 1.4.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Acontplus.Core --version 1.4.4
                    
NuGet\Install-Package Acontplus.Core -Version 1.4.4
                    
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="Acontplus.Core" Version="1.4.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Acontplus.Core" Version="1.4.4" />
                    
Directory.Packages.props
<PackageReference Include="Acontplus.Core" />
                    
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 Acontplus.Core --version 1.4.4
                    
#r "nuget: Acontplus.Core, 1.4.4"
                    
#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 Acontplus.Core@1.4.4
                    
#: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=Acontplus.Core&version=1.4.4
                    
Install as a Cake Addin
#tool nuget:?package=Acontplus.Core&version=1.4.4
                    
Install as a Cake Tool

Acontplus.Core

NuGet .NET License

A cutting-edge .NET 9+ foundational library leveraging the latest C# language features and modern enterprise patterns. Built with performance, type safety, and developer experience in mind.

🚀 .NET 9 Modern Features

🎯 Latest C# Language Features

  • Collection Expressions - Modern [] syntax for efficient collection initialization
  • Primary Constructors - Concise record and class definitions
  • Required Properties - Compile-time null safety with required keyword
  • Pattern Matching - Advanced switch expressions and is patterns
  • Record Structs - High-performance value types for DTOs and results
  • Nullable Reference Types - Full compile-time null safety
  • Source Generators - JSON serialization with AOT compilation support
  • Global Usings - Clean namespace management with global using directives

🏗️ Modern Architecture Patterns

  • Domain-Driven Design (DDD) - Complete DDD implementation with modern C# features
  • Functional Result Pattern - Railway-oriented programming with record structs
  • Repository Pattern - Comprehensive data access with bulk operations
  • Specification Pattern - Type-safe query composition with expressions
  • Event Sourcing Ready - Domain events with modern event patterns

📊 Advanced Data Patterns

  • Async Streaming - IAsyncEnumerable<T> for memory-efficient processing
  • Projections - Expression-based data transfer for performance
  • Bulk Operations - High-performance batch processing with EF Core 9
  • Smart Pagination - Advanced pagination with search and filtering
  • Modern JSON - System.Text.Json with source generation

🔥 Cutting-Edge Features

🎯 Modern Entity System

// Modern entity with required properties and collection expressions
public class Product : BaseEntity
{
    public required string Name { get; set; }
    public required decimal Price { get; set; }
    public string? Description { get; set; }
    public required int CategoryId { get; set; }
    
    // Factory method with modern syntax
    public static Product Create(int id, string name, decimal price, string description, int categoryId, int createdByUserId) =>
        new()
        {
            Id = id,
            Name = name,
            Price = price,
            Description = description,
            CategoryId = categoryId,
            CreatedAt = DateTime.UtcNow,
            CreatedByUserId = createdByUserId
        };
}

🔄 Functional Result Pattern

// Modern result pattern with record structs
public async Task<Result<Product>> GetProductAsync(int id)
{
    var product = await _repository.GetByIdAsync(id);
    
    return product is not null 
        ? Result<Product>.Success(product)
        : Result<Product>.Failure(DomainError.NotFound("PRODUCT_NOT_FOUND", $"Product {id} not found"));
}

// Pattern matching with modern syntax
var response = result.Match(
    success: product => ApiResponse<Product>.Success(product),
    failure: error => error.ToApiResponse<Product>()
);

📊 Modern Pagination

// Collection expressions and modern initialization
var pagination = new PaginationDto
{
    PageIndex = 1,
    PageSize = 20,
    SortBy = "CreatedAt",
    SortDirection = SortDirection.Descending,
    SearchTerm = "search term",
    Filters = new Dictionary<string, object>
    {
        ["CategoryId"] = 1,
        ["IsActive"] = true
    }
};

// Modern specification pattern
public class ActiveProductsSpecification : BaseSpecification<Product>
{
    public ActiveProductsSpecification(PaginationDto pagination) : base(p => p.IsActive)
    {
        ApplyPaging(pagination);
        AddOrderBy(p => p.CreatedAt, isDescending: true);
        AddInclude(p => p.Category);
    }
}

🚀 Async Streaming & Projections

// Memory-efficient async streaming
await foreach (var product in repository.FindAsyncEnumerable(p => p.IsActive))
{
    await ProcessProductAsync(product);
}

// High-performance projections
var summaries = await repository.GetPagedProjectionAsync(
    pagination,
    p => new ProductSummary(p.Id, p.Name, p.Price),
    p => p.IsActive
);

🔥 Modern JSON Extensions

// Enterprise-optimized JSON with source generation
var json = myObject.SerializeModern();
var obj = jsonString.DeserializeModern<MyType>();
var clone = myObject.CloneViaJson();

// Modern JSON options for different scenarios
var options = JsonExtensions.DefaultOptions; // Production
var prettyOptions = JsonExtensions.PrettyOptions; // Development
var strictOptions = JsonExtensions.StrictOptions; // APIs

🎯 Modern Error Handling

// Modern error creation with record structs
var validationError = DomainError.Validation(
    code: "PRODUCT_INVALID_PRICE",
    message: "Product price must be greater than zero",
    target: "price"
);

// Error aggregation with modern LINQ
var errors = new List<DomainError>();
if (string.IsNullOrWhiteSpace(request.Name))
    errors.Add(DomainError.Validation("INVALID_NAME", "Product name is required"));

if (errors.Any())
    return Result<Product>.Failure(errors.GetMostSevereError());

📦 Installation

NuGet Package Manager

Install-Package Acontplus.Core

.NET CLI

dotnet add package Acontplus.Core

PackageReference

<PackageReference Include="Acontplus.Core" Version="1.3.3" />

🎯 Quick Start with .NET 9

1. Modern Entity Definition

// Modern entity with required properties
public class Product : BaseEntity
{
    public required string Name { get; set; }
    public required decimal Price { get; set; }
    public string? Description { get; set; }
    public required int CategoryId { get; set; }
    
    // Factory method with modern syntax
    public static Product Create(int id, string name, decimal price, string description, int categoryId, int createdByUserId) =>
        new()
        {
            Id = id,
            Name = name,
            Price = price,
            Description = description,
            CategoryId = categoryId,
            CreatedAt = DateTime.UtcNow,
            CreatedByUserId = createdByUserId
        };
}

2. Modern Error Handling

// Modern error creation with record structs
var validationError = DomainError.Validation(
    code: "PRODUCT_INVALID_PRICE",
    message: "Product price must be greater than zero",
    target: "price"
);

// Pattern matching with modern syntax
var response = result.Match(
    success: product => ApiResponse<Product>.Success(product),
    failure: error => error.ToApiResponse<Product>()
);

3. Modern Repository Pattern

// Modern repository interface
public interface IProductRepository : IRepository<Product>
{
    Task<IReadOnlyList<Product>> GetByCategoryAsync(int categoryId);
    Task<bool> ExistsByNameAsync(string name);
}

// Modern repository implementation
public class ProductRepository : BaseRepository<Product>, IProductRepository
{
    public ProductRepository(DbContext context) : base(context) { }
    
    public async Task<IReadOnlyList<Product>> GetByCategoryAsync(int categoryId) =>
        await FindAsync(p => p.CategoryId == categoryId);
    
    public async Task<bool> ExistsByNameAsync(string name) =>
        await ExistsAsync(p => p.Name == name);
}

4. Modern Specification Pattern

// Modern specification with primary constructor
public class ActiveProductsSpecification : BaseSpecification<Product>
{
    public ActiveProductsSpecification(PaginationDto pagination) : base(p => p.IsActive)
    {
        ApplyPaging(pagination);
        AddOrderBy(p => p.CreatedAt, isDescending: true);
        AddInclude(p => p.Category);
    }
}

// Usage with modern syntax
var spec = new ActiveProductsSpecification(new PaginationDto { PageIndex = 1, PageSize = 10 });
var products = await _repository.FindWithSpecificationAsync(spec);

5. Modern API Response Handling

[HttpGet("{id}")]
public async Task<ApiResponse<ProductDto>> GetProduct(int id)
{
    var result = await _productService.GetByIdAsync(id);
    
    return result.Match(
        success: product => ApiResponse<ProductDto>.Success(product.ToDto()),
        failure: error => error.ToApiResponse<ProductDto>()
    );
}

🔧 Advanced .NET 9 Features

Modern Domain Events

// Modern domain event with record
public record ProductCreatedEvent(int ProductId, string ProductName, DateTime OccurredOn) : IDomainEvent
{
    public ProductCreatedEvent(int productId, string productName) : this(productId, productName, DateTime.UtcNow) { }
}

// Modern entity with domain events
public class Product : BaseEntity
{
    public void MarkAsCreated() =>
        AddDomainEvent(new ProductCreatedEvent(Id, Name));
}

Modern Bulk Operations

// High-performance bulk operations
await repository.BulkInsertAsync(products);
await repository.BulkUpdateAsync(p => p.CategoryId == 1, p => p.Status, "Active");
await repository.BulkDeleteAsync(p => p.CreatedAt < DateTime.UtcNow.AddDays(-30));

// Modern projections for efficient data transfer
var summaries = await repository.GetPagedProjectionAsync(
    pagination,
    p => new ProductSummary(p.Id, p.Name, p.Price),
    p => p.IsActive
);

Modern Async Streaming

// Memory-efficient processing with async streaming
await foreach (var product in repository.FindAsyncEnumerable(p => p.IsActive))
{
    await ProcessProductAsync(product);
}

Modern JSON Handling

// Enterprise-optimized JSON with source generation
var json = myObject.SerializeModern();
var obj = jsonString.DeserializeModern<MyType>();
var clone = myObject.CloneViaJson();

// Modern JSON options for different scenarios
var options = JsonExtensions.DefaultOptions; // Production
var prettyOptions = JsonExtensions.PrettyOptions; // Development
var strictOptions = JsonExtensions.StrictOptions; // APIs

🏗️ Modern Architecture Patterns

Domain-Driven Design

  • Modern Entities: Record-based entities with primary constructors
  • Value Objects: Immutable objects with modern C# features
  • Domain Events: Record-based events with modern patterns
  • Specifications: Type-safe query composition with expressions

Repository Pattern

  • Generic Repository: Type-safe data access with modern features
  • Specification Pattern: Flexible query composition with modern syntax
  • Unit of Work: Transaction management with modern patterns
  • Bulk Operations: High-performance batch processing with EF Core 9

Error Handling

  • Domain Errors: Record struct-based error types with HTTP mapping
  • Result Pattern: Functional error handling with modern syntax
  • API Responses: Consistent error response format with modern features
  • Error Aggregation: Multiple error handling with modern LINQ

🔍 Modern Validation Examples

// Modern validation with pattern matching
var validationResult = input switch
{
    { Length: 0 } => DomainError.Validation("EMPTY_INPUT", "Input cannot be empty"),
    { Length: > 100 } => DomainError.Validation("TOO_LONG", "Input too long"),
    _ => null
};

// Modern JSON validation
if (!DataValidation.IsValidJson(jsonContent))
{
    return DomainError.Validation("INVALID_JSON", "Invalid JSON format");
}

📚 Modern API Documentation

Entity Base Classes

  • Entity<TId> - Modern base entity with domain events
  • BaseEntity - Modern base for int-keyed entities with audit trail
  • IAuditableEntity - Interface for audit trail support
  • IEntityWithDomainEvents - Interface for domain event support

DTOs

  • ApiResponse<T> - Modern API response format with record structs
  • PaginationDto - Modern pagination with search and filtering
  • PagedResult<T> - Modern paginated results with metadata
  • ApiError - Modern error information with record structs

Error Handling

  • DomainError - Modern business logic errors with HTTP mapping
  • Result<T> - Modern functional result pattern with record structs
  • ErrorType - Modern error type categorization
  • ErrorTypeExtensions - Modern error type utilities

Repository

  • IRepository<TEntity> - Modern comprehensive repository interface
  • ISpecification<T> - Modern query specification pattern
  • BaseSpecification<T> - Modern base class for specifications
  • PagedResult<T> - Modern paginated query results

Modern Features

  • Collection Expressions: [] syntax for modern collection initialization
  • Required Properties: Compile-time null safety with required keyword
  • Record Structs: High-performance value types for DTOs and results
  • Primary Constructors: Concise type definitions with modern syntax
  • Pattern Matching: Advanced type-safe operations with modern patterns
  • Async Streaming: Memory-efficient data processing with IAsyncEnumerable<T>
  • Source Generation: JSON serialization with AOT compilation support

🆕 What's New in Version 1.3.3

.NET 9 Modern Features

  • Primary Constructors: Concise record and class definitions
  • Collection Expressions: Modern [] syntax for efficient initialization
  • Required Properties: Compile-time null safety with required keyword
  • Record Structs: High-performance value types for DTOs and results
  • Pattern Matching: Advanced switch expressions and is patterns
  • Source Generators: JSON serialization with AOT compilation support
  • Global Usings: Clean namespace management with global using directives

Performance Improvements

  • Source Generation: JSON serialization with source generation for AOT
  • Record Structs: High-performance value types for DTOs and results
  • Collection Expressions: Modern collection initialization with better performance
  • Async Streaming: Memory-efficient data processing with IAsyncEnumerable<T>
  • Bulk Operations: Optimized batch processing with EF Core 9

Developer Experience

  • Modern C# Features: Latest .NET 9+ language capabilities
  • Type Safety: Enhanced compile-time safety with modern features
  • Better Documentation: Comprehensive examples with modern syntax
  • Error Handling: Improved error aggregation with modern patterns

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

git clone https://github.com/Acontplus-S-A-S/acontplus-dotnet-libs.git
cd acontplus-dotnet-libs
dotnet restore
dotnet build

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

  • 📧 Email: proyectos@acontplus.com
  • 🐛 Issues: GitHub Issues
  • 📖 Documentation: Wiki

👨‍💻 Author

Ivan Paz - @iferpaz7

🏢 Company

Acontplus S.A.S. - Enterprise software solutions


Built with ❤️ for the .NET community using the latest .NET 9 features

Product Compatible and additional computed target framework versions.
.NET 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 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.
  • net9.0

    • No dependencies.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Acontplus.Core:

Package Downloads
Acontplus.Persistence.SqlServer

Advanced library for SQL Server persistence with Entity Framework Core integration. Includes repositories, context management, ADO.NET support, advanced error handling, and enterprise-ready data access patterns for SQL Server databases.

Acontplus.Utilities

Comprehensive utilities library with cross-cutting concerns and general-purpose tools. Includes encryption, IO operations, text processing, time utilities, API helpers, JSON utilities, and security features for enterprise applications.

Acontplus.FactElect

Complete library for electronic invoicing and SRI integration in Ecuador. Includes models, services, XML validation, SRI web service support, and embedded XSD schemas for compliance.

Acontplus.Notifications

Comprehensive library for notification services. Includes email (MailKit, Amazon SES), WhatsApp, push notifications, templating with Scriban, queue management, and enterprise-ready delivery patterns for cloud-native applications.

Acontplus.Reports

Advanced library for comprehensive report generation and management. Includes RDLC report processing, PDF/Excel export capabilities, ReportViewer integration, template support, and enterprise-ready reporting patterns for business applications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.7 0 8/21/2025
1.4.6 0 8/21/2025
1.4.5 12 8/19/2025
1.4.4 92 8/8/2025
1.4.3 92 8/8/2025
1.4.2 163 8/7/2025
1.4.1 164 8/7/2025
1.4.0 163 8/7/2025
1.3.2 526 7/23/2025
1.3.1 103 7/18/2025
1.3.0 189 7/14/2025
1.2.10 128 7/14/2025
1.2.9 161 7/14/2025
1.2.8 107 7/11/2025
1.2.7 117 7/11/2025
1.2.6 166 7/10/2025
1.2.5 128 7/10/2025
1.2.4 131 7/10/2025
1.2.3 126 7/10/2025
1.2.2 129 7/10/2025
1.2.1 161 7/10/2025
1.2.0 159 7/10/2025
1.1.11 161 7/9/2025
1.1.10 222 7/6/2025
1.1.9 129 7/6/2025
1.1.8 132 7/6/2025
1.1.7 165 7/6/2025
1.1.6 133 7/6/2025
1.1.5 136 7/6/2025
1.1.4 147 7/4/2025
1.1.3 186 7/2/2025
1.1.2 163 7/2/2025
1.1.1 134 7/2/2025
1.1.0 198 7/1/2025

Enhanced with cutting-edge C# features: collection expressions, required properties, record structs, and source generation. Improved error handling with comprehensive HTTP status code mapping, functional result patterns, and domain event system. Added advanced pagination with search and filtering, powerful JSON utilities with multiple serialization options, XML validation helpers, and enterprise-ready abstractions for repository pattern and specification queries. Optimized for AOT compilation and contemporary C# development patterns.