Database-Agnostic Data Access Framework for .NET
Syrx is a .NET database abstraction framework that decouples your repository code from underlying data stores while emphasizing:
- 🎮 Control - Full developer control over data and execution
- ⚡ Speed - Built on Dapper for maximum performance
- 🔄 Flexibility - Easily switch between database technologies
- 🧪 Testability - Fully testable at all levels
- 🔧 Extensibility - Granular, componentized architecture
- 📖 Readability - Clear, concise code intent
# Choose your database provider
dotnet add package Syrx.SqlServer.Extensions # SQL Server
dotnet add package Syrx.MySql.Extensions # MySQL
dotnet add package Syrx.Npgsql.Extensions # PostgreSQL
dotnet add package Syrx.Oracle.Extensions # Oracle
// Program.cs
services.UseSyrx(syrx => syrx
.UseSqlServer(sqlServer => sqlServer
.AddConnectionString("default", connectionString)
.AddCommand<ProductRepository>(commands => commands
.ForMethod(nameof(ProductRepository.GetAllAsync), cmd => cmd
.UseConnectionAlias("default")
.UseCommandText("SELECT * FROM Products")))));
public class ProductRepository(ICommander<ProductRepository> commander)
{
private readonly ICommander<ProductRepository> _commander = commander;
public async Task<IEnumerable<Product>> GetAllAsync()
=> await _commander.QueryAsync<Product>();
}
Syrx provides a clean separation between your application logic and data access:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Repository │───▶│ ICommander │───▶│ DatabaseProvider │
│ │ │ │ │ │
│ Business Logic │ │ Query/Execute │ │ SQL Server │
│ │ │ Operations │ │ MySQL/Postgres │
└─────────────────┘ └─────────────────┘ │ Oracle │
└─────────────────┘
Package | Description | NuGet |
---|---|---|
Syrx | Core abstractions and interfaces | |
Syrx.Settings | Configuration settings and abstractions |
Provider | Package | NuGet |
---|---|---|
SQL Server | Syrx.SqlServer.Extensions | |
MySQL | Syrx.MySql.Extensions | |
PostgreSQL | Syrx.Npgsql.Extensions | |
Oracle | Syrx.Oracle.Extensions |
Switch between SQL Server, MySQL, PostgreSQL, and Oracle with configuration changes only 8000 .
Inherit all of Dapper's performance benefits while gaining additional abstraction layers.
Automatic mapping from method names to SQL commands using [CallerMemberName]
attribute.
Handle complex object composition with support for up to 16 input parameters.
Full test coverage with unit and integration tests for all database providers.
- 📖 Wiki - Complete documentation and guides
- 🚀 Getting Started - Installation and setup
- ⚙️ Configuration - Configuration examples
- 🗄️ Database Providers - Provider-specific guides
- 🔄 Migration Guides - Migration from other frameworks
- 💬 Discussions - Ask questions and share ideas
- 🐛 Issues - Report bugs and request features
- 📋 Projects - View roadmap and progress
services.UseSyrx(syrx => syrx
.UseSqlServer(sql => sql.AddConnectionString("primary", sqlConnection))
.UseNpgsql(pg => pg.AddConnectionString("analytics", pgConnection)));
public async Task<IEnumerable<Order>> GetOrdersWithCustomersAsync()
=> await _commander.QueryAsync<Order, Customer, Order>(
(order, customer) => { order.Customer = customer; return order; });
public async Task<bool> TransferInventoryAsync(int fromId, int toId, int quantity)
=> await _commander.ExecuteAsync(new { fromId, toId, quantity });
We welcome contributions! Please see our Contributing Guide for details.
- Clone the repository
- Install .NET 8.0+ SDK
- Run
dotnet restore
- Run
dotnet test
to verify setup
This project is licensed under the MIT License - see the LICENSE file for details.
- Built on top of the excellent Dapper micro-ORM
- Inspired by the need for flexible, testable data access patterns
- Community feedback and contributions that make this framework better
Get Started • View Examples • Browse Packages
Made with ❤️ by the Syrx community