Acontplus.Persistence.PostgreSQL
1.0.12
See the version list below for details.
dotnet add package Acontplus.Persistence.PostgreSQL --version 1.0.12
NuGet\Install-Package Acontplus.Persistence.PostgreSQL -Version 1.0.12
<PackageReference Include="Acontplus.Persistence.PostgreSQL" Version="1.0.12" />
<PackageVersion Include="Acontplus.Persistence.PostgreSQL" Version="1.0.12" />
<PackageReference Include="Acontplus.Persistence.PostgreSQL" />
paket add Acontplus.Persistence.PostgreSQL --version 1.0.12
#r "nuget: Acontplus.Persistence.PostgreSQL, 1.0.12"
#:package Acontplus.Persistence.PostgreSQL@1.0.12
#addin nuget:?package=Acontplus.Persistence.PostgreSQL&version=1.0.12
#tool nuget:?package=Acontplus.Persistence.PostgreSQL&version=1.0.12
Acontplus.Persistence.PostgreSQL
PostgreSQL implementation of the Acontplus persistence layer. Provides optimized Entity Framework Core integration, ADO.NET repositories, and PostgreSQL-specific features for high-performance data access.
Note: This package implements the abstractions defined in Acontplus.Persistence.Common. For general persistence patterns and repository interfaces, see the common package.
🚀 PostgreSQL-Specific Features
- PostgreSQL Optimization - Query optimizations and connection pooling for PostgreSQL
- Advanced Error Translation - PostgreSQL error code mapping to domain exceptions
- JSON/JSONB Support - Native JSON operations and indexing
- Array Types - PostgreSQL array type handling and operations
- Full-Text Search - PostgreSQL full-text search integration
- Performance Monitoring - Query execution statistics and performance insights
📦 Installation
NuGet Package Manager
Install-Package Acontplus.Persistence.PostgreSQL
.NET CLI
dotnet add package Acontplus.Persistence.PostgreSQL
PackageReference
<ItemGroup>
<PackageReference Include="Acontplus.Persistence.PostgreSQL" Version="1.0.10" />
<PackageReference Include="Acontplus.Persistence.Common" Version="1.1.13" />
</ItemGroup>
🎯 Quick Start
1. Configure PostgreSQL Context
services.AddDbContext<BaseContext>(options =>
options.UseNpgsql(connectionString, npgsqlOptions =>
{
npgsqlOptions.EnableRetryOnFailure(3, TimeSpan.FromSeconds(30), null);
npgsqlOptions.CommandTimeout(60);
}));
services.AddScoped(typeof(IRepository<>), typeof(BaseRepository<>));
2. Use Repository Pattern
public class UserService
{
private readonly IRepository<User> _userRepository;
public UserService(IRepository<User> userRepository)
{
_userRepository = userRepository;
}
public async Task<Result<User>> GetUserByIdAsync(int id)
{
var user = await _userRepository.GetByIdAsync(id);
return user != null
? Result<User>.Success(user)
: Result<User>.Failure(DomainError.NotFound("USER_NOT_FOUND", $"User {id} not found"));
}
}
3. Advanced Query Operations
// Complex queries with PostgreSQL optimizations
public async Task<IReadOnlyList<OrderSummary>> GetOrderSummariesAsync(
DateTime startDate,
CancellationToken ct = default)
{
var queryExpression = (IQueryable<Order> q) => q
.Where(o => o.CreatedAt >= startDate)
.Join(_context.Set<Customer>(),
order => order.CustomerId,
customer => customer.Id,
(order, customer) => new { Order = order, Customer = customer })
.Select(x => new OrderSummary
{
OrderId = x.Order.Id,
CustomerName = $"{x.Customer.FirstName} {x.Customer.LastName}",
TotalAmount = x.Order.TotalAmount,
Status = x.Order.Status
});
return await _orderRepository.ExecuteQueryToListAsync(queryExpression, ct);
}
🔧 PostgreSQL Configuration
Connection String Best Practices
{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Database=MyApp;Username=myuser;Password=mypass;SSL Mode=Require;Trust Server Certificate=true;"
}
}
Performance Tuning
services.AddDbContext<BaseContext>(options =>
{
options.UseNpgsql(connectionString, npgsqlOptions =>
{
// Connection resilience
npgsqlOptions.EnableRetryOnFailure(
maxRetryCount: 5,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorCodesToAdd: null);
// Performance settings
npgsqlOptions.CommandTimeout(60);
npgsqlOptions.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
});
// Additional performance options
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
options.EnableSensitiveDataLogging(false);
});
📚 PostgreSQL API Reference
BaseContext- Optimized EF Core context for PostgreSQLAdoRepository- ADO.NET operations with PostgreSQL-specific error handlingPostgresExceptionTranslator- Maps PostgreSQL error codes to domain exceptionsJsonOperations- JSON/JSONB query and manipulation utilitiesFullTextSearch- PostgreSQL full-text search integration
🤝 Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Setup
git clone https://github.com/acontplus/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 - Software solutions
Built with ❤️ for the .NET community
| Product | Versions 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. |
-
net9.0
- Acontplus.Core (>= 1.5.8)
- Acontplus.Persistence.Common (>= 1.1.15)
- Microsoft.EntityFrameworkCore (>= 9.0.10)
- Microsoft.Extensions.Caching.Memory (>= 9.0.10)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.10)
- Microsoft.Extensions.DependencyInjection (>= 9.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.10)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.10)
- Npgsql (>= 9.0.4)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.4)
- Polly (>= 8.6.4)
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 |
|---|---|---|
| 1.1.4 | 63 | 11/6/2025 |
| 1.1.3 | 65 | 11/6/2025 |
| 1.1.2 | 61 | 11/6/2025 |
| 1.1.1 | 70 | 11/5/2025 |
| 1.1.0 | 81 | 11/5/2025 |
| 1.0.12 | 168 | 10/23/2025 |
| 1.0.11 | 150 | 9/26/2025 |
| 1.0.10 | 168 | 9/25/2025 |
| 1.0.9 | 164 | 9/24/2025 |
| 1.0.8 | 223 | 9/14/2025 |
| 1.0.7 | 220 | 9/14/2025 |
| 1.0.6 | 227 | 9/14/2025 |
| 1.0.5 | 179 | 9/10/2025 |
| 1.0.4 | 164 | 9/9/2025 |
| 1.0.3 | 198 | 8/24/2025 |
| 1.0.2 | 163 | 8/21/2025 |
| 1.0.1 | 160 | 8/19/2025 |
| 1.0.0 | 172 | 8/12/2025 |
Enhanced with contemporary repository patterns, Entity Framework Core integration, Npgsql support, advanced error handling, connection resilience with Polly, and enterprise-ready PostgreSQL data access patterns.