NestXRepository.Core
2.3.3
dotnet add package NestXRepository.Core --version 2.3.3
NuGet\Install-Package NestXRepository.Core -Version 2.3.3
<PackageReference Include="NestXRepository.Core" Version="2.3.3" />
<PackageVersion Include="NestXRepository.Core" Version="2.3.3" />
<PackageReference Include="NestXRepository.Core" />
paket add NestXRepository.Core --version 2.3.3
#r "nuget: NestXRepository.Core, 2.3.3"
#:package NestXRepository.Core@2.3.3
#addin nuget:?package=NestXRepository.Core&version=2.3.3
#tool nuget:?package=NestXRepository.Core&version=2.3.3
NestXRepository.Core
Librería de acceso a datos de alto rendimiento para .NET 10+ que combina la velocidad de Dapper con el poder de Entity Framework Core, optimizada para PostgreSQL con arquitectura multi-base de datos.
¿Qué problema resuelve?
Escoge la herramienta correcta para cada escenario sin duplicar código:
- Queries de lectura masivas (>1000 registros) → Dapper (3x más rápido)
- CRUD con relaciones complejas → Entity Framework
- Inserciones masivas (>100 registros) → BulkInsert (25x más rápido)
- Filtros dinámicos complejos → EFQueryable con LINQ
- Reports con múltiples JOINs → DPQueryJoin
Todo en una sola interfaz. Cero configuración duplicada.
Instalación
dotnet add package NestXRepository.Core
Requisitos:
- .NET 10.0+
- PostgreSQL 12+ (SQL Server y MySQL preparados para futuras versiones)
- Entity Framework Core 10.0+
- Dapper 2.1+
- Npgsql 10.0+
Quick Start
1. Configuración (Una línea)
// Program.cs
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<MyDbContext>(options =>
options.UseNpgsql(connectionString));
// Registra automáticamente IGenericRepository<T> para todas tus entidades
builder.Services.AddGenericRepository<MyDbContext>(connectionString);
2. Uso en tus servicios
public class ProductService
{
private readonly IGenericRepository<Product> _repo;
public ProductService(IGenericRepository<Product> repo) => _repo = repo;
// Lectura rápida con Dapper
public async Task<List<Product>> GetActiveProducts()
=> await _repo.DPGetAll(p => p.IsActive, top: 100);
// CRUD completo con EF
public async Task<Guid> CreateProduct(Product product)
=> await _repo.EFAdd<Guid>(product);
// Queries dinámicas complejas
public async Task<List<Product>> SearchProducts(string? name, bool? inStock)
{
var query = _repo.EFQueryable()
.Where(p => p.IsActive);
if (!string.IsNullOrEmpty(name))
query = query.Where(p => p.Name.Contains(name));
if (inStock.HasValue)
query = query.Where(p => p.Stock > 0);
return await query.Include(p => p.Category).ToListAsync();
}
}
Características Principales
| Característica | Descripción |
|---|---|
| Dual ORM | Dapper (DP*) para alto rendimiento + EF Core (EF*) para operaciones ORM completas |
| Multi-Base de Datos | Arquitectura ISqlDialect - PostgreSQL activo, SQL Server y MySQL preparados |
| BulkInsert Optimizado | PostgreSQL BINARY COPY - hasta 25x más rápido que inserts tradicionales |
| Case-Insensitive Inteligente | Maneja automáticamente mayúsculas/minúsculas en PostgreSQL |
| Foreign Keys Automáticas | Carga lazy de relaciones con caching y paralelización |
| SoftDelete | Borrado lógico con soporte completo para relaciones |
| Paginación Built-in | Para Dapper y EF con cálculo automático de totales |
| Queries Dinámicas | EFQueryable para construir queries LINQ complejas |
| JOINs Avanzados | DPQueryJoin para 2 y 3 tablas con Dapper |
| Unit of Work | Transacciones compartidas entre Dapper y EF Core |
| CancellationToken | Soporte completo para operaciones async cancelables |
| Performance Cache | Caching inteligente de metadata, properties y setters compilados |
Documentación
- Referencia Técnica Completa - Referencia de todos los métodos con ejemplos
- Arquitectura y Diseño - Patrones de diseño, decisiones técnicas y optimizaciones
Casos de Uso
Lectura de Alto Rendimiento
// 10,000 registros en ~180ms (vs 420ms con EF puro)
var products = await _repo.DPGetAll(p => p.IsActive, top: 10000);
Inserciones Masivas
// 10,000 inserts en ~350ms (vs 8,500ms con EF tradicional)
var insertedIds = _repo.BulkInsert(products, includeForeignKeys: false);
Queries Dinámicas Complejas
var query = _repo.EFQueryable()
.Where(u => u.IsActive)
.Where(u => u.CreatedAt >= DateTime.Now.AddMonths(-1))
.Include(u => u.Orders)
.ThenInclude(o => o.OrderDetails)
.OrderByDescending(u => u.CreatedAt)
.Select(u => new UserSummary
{
Name = u.Name,
OrderCount = u.Orders.Count
});
var result = await query.ToListAsync();
JOINs Multi-Tabla con Dapper
var sql = @"
SELECT u.*, o.*, p.*
FROM users u
INNER JOIN orders o ON u.id = o.userid
INNER JOIN products p ON o.productid = p.id
WHERE u.isactive = true";
var result = await _repo.DPQueryJoin<User, Order, Product, UserOrderDto>(
sql,
(user, order, product) => new UserOrderDto
{
UserName = user.Name,
OrderId = order.Id,
ProductName = product.Name
},
splitOn: "id,id"
);
Arquitectura
GenericRepository.Core/
├── Dialects/ # Abstracción multi-base de datos
│ ├── ISqlDialect.cs
│ ├── PostgreSqlDialect.cs # Activo
│ ├── SqlServerDialect.cs # Preparado
│ └── MySqlDialect.cs # Preparado
├── Interfaces/
│ └── IGenericRepository.cs
├── Repositories/ # Clase parcial dividida en 11 archivos
│ ├── GenericRepository.cs # Constructores y configuración
│ ├── GenericRepository.BulkOps.cs # PostgreSQL COPY
│ ├── GenericRepository.DapperQueries.cs
│ ├── GenericRepository.Delete.cs
│ ├── GenericRepository.EFQueries.cs
│ ├── GenericRepository.ExpressionConverter.cs
│ ├── GenericRepository.Helpers.cs
│ ├── GenericRepository.Insert.cs
│ ├── GenericRepository.Internals.cs
│ ├── GenericRepository.SoftDelete.cs
│ ├── GenericRepository.Update.cs
│ ├── ConnectionProvider.cs
│ └── ServiceCollectionExtensions.cs
├── unit/
│ ├── IDapperUnitOfWork.cs
│ └── DapperUnitOfWork.cs
└── docs/ # Documentación técnica
Testing
# Todos los tests
dotnet test
# Por categoría
dotnet test --filter "FullyQualifiedName~Infrastructure"
dotnet test --filter "FullyQualifiedName~EF"
dotnet test --filter "FullyQualifiedName~ForeignKey"
dotnet test --filter "FullyQualifiedName~Performance"
dotnet test --filter "FullyQualifiedName~Transactions"
dotnet test --filter "FullyQualifiedName~Security"
Benchmarks
Mediciones en PostgreSQL con 100,000 registros:
| Operación | Dapper | Entity Framework | BulkInsert | Ganador |
|---|---|---|---|---|
| SELECT 10K rows | 180ms | 420ms | - | Dapper 2.3x |
| SELECT con 1 JOIN | 250ms | 680ms | - | Dapper 2.7x |
| INSERT 1K rows | 850ms | 2400ms | 90ms | Bulk 27x |
| INSERT 10K rows | - | - | 350ms | Bulk 24x |
| UPDATE 1K rows | 780ms | 2100ms | - | Dapper 2.7x |
Contribuciones
Este proyecto es propietario de NestX Software. Para reportar bugs o sugerir mejoras, contacta al equipo de desarrollo.
Licencia
Propietaria - NestX Software © 2026
Recursos Adicionales
- Comparativa Dapper vs EF - Guía de cuándo usar cada uno
- Patrones de Optimización - Caching, paralelización, bulk operations
| 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
- Dapper (>= 2.1.66)
- Microsoft.EntityFrameworkCore (>= 10.0.0)
- Npgsql (>= 10.0.0)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.0)
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.3 | 131 | 6/14/2026 |
| 2.3.1 | 1,592 | 4/18/2026 |
| 2.2.0 | 311 | 4/15/2026 |
| 2.1.0 | 123 | 4/14/2026 |
| 2.0.3 | 128 | 4/1/2026 |
| 2.0.2 | 119 | 3/20/2026 |
| 2.0.1 | 118 | 2/27/2026 |
| 2.0.0 | 122 | 2/27/2026 |
| 1.1.8 | 131 | 1/4/2026 |
| 1.1.7 | 144 | 1/4/2026 |
| 1.1.6 | 140 | 1/2/2026 |
| 1.1.5 | 139 | 12/26/2025 |
| 1.1.4 | 449 | 12/11/2025 |
| 1.1.3 | 688 | 12/1/2025 |
| 1.1.2 | 149 | 11/29/2025 |
| 1.1.1 | 211 | 11/25/2025 |
| 1.1.0 | 216 | 7/7/2025 |
| 1.0.9 | 213 | 7/2/2025 |
| 1.0.8 | 206 | 6/25/2025 |
| 1.0.7 | 168 | 5/31/2025 |