A Dapper wrapper that uses string interpolation and a fluent API to safely build dynamic SQL queries with automatic parameterization.
Dapper Query Builder is a C# library that extends Dapper by providing a safe and intuitive way to build dynamic SQL queries using string interpolation and a fluent API. It solves the problem of cumbersome parameter management and dynamic filter construction in Dapper by automatically converting interpolated values into SQL parameters, preventing SQL injection while keeping code clean and readable.
C# developers using Dapper for database access who need to construct dynamic queries with variable filters, conditions, or clauses, and want to avoid the boilerplate of manual parameter handling.
Developers choose Dapper Query Builder because it combines the safety of parameterized queries with the convenience of string interpolation, eliminating the need for verbose DynamicParameters or anonymous objects. Its fluent API and dynamic keyword support make building complex queries straightforward without introducing new abstractions or sacrificing Dapper's performance.
Dapper Query Builder using String Interpolation and Fluent API
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically converts interpolated values into SQL parameters, preventing injection while maintaining Dapper's performance, as shown in examples where variables like {productName} are securely parameterized.
Simplifies adding filters with a fluent API and keywords like /**where**/, eliminating the need for manual DynamicParameters management when constructing queries with variable conditions.
Works with any ADO.NET provider (SQL Server, PostgreSQL, etc.) by using vendor-agnostic parameter prefixes, ensuring flexibility across different databases without code changes.
Handles spacing, trims multi-line queries, and reuses duplicate parameters automatically, reducing boilerplate and improving readability in complex SQL statements.
The README states it's now a facade for InterpolatedSql.Dapper, meaning new features and bug fixes are prioritized in the successor library, potentially leaving users behind.
The :raw modifier allows embedding untrusted SQL strings, which can introduce injection vulnerabilities if misused, requiring careful sanitization and review as warned in the documentation.
Relies on string interpolation for query building, which lacks compile-time validation and can lead to runtime errors or maintenance challenges compared to typed ORM approaches.
Tightly coupled to Dapper, so if a project evolves beyond Dapper or adopts a different micro-ORM, this library becomes obsolete, limiting long-term flexibility.