A .NET library for building injection-safe SQL statements using string interpolation syntax.
InterpolatedSql is a .NET library that allows developers to build SQL statements using C# string interpolation syntax. It automatically converts interpolated values into parameterized SQL, preventing SQL injection while maintaining readable, dynamic query construction. The library is database-agnostic and designed to integrate with existing ADO.NET data layers.
Developers working with .NET who need to dynamically build parameterized SQL queries, especially those using ADO.NET directly or integrating with micro-ORMs like Dapper.
It provides a natural, intuitive syntax for SQL building without compromising security, eliminating the need to manually manage separate StringBuilder and parameter dictionary objects. Its database-agnostic design makes it flexible for various data access scenarios.
Sql Builder using Interpolated Strings
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Extracts interpolated values as SQL parameters automatically, preventing SQL injection without manual parameter management, as shown in examples where {categoryId} becomes @p0.
Supports appending conditional clauses with += operator or AppendIf methods, enabling readable dynamic SQL for filters, as demonstrated in the README with conditional WHERE clauses.
Works with any ADO.NET-based data layer without tying to a specific database, making it versatile for various .NET data access scenarios, as emphasized in its design philosophy.
Uses InterpolatedStringHandlers for efficient parsing without regex, leveraging modern .NET features for better performance and cleaner code, as mentioned in the key features.
Only builds SQL strings and parameters; it lacks built-in execution methods, requiring manual integration with data access layers, which the README admits by recommending separate packages like InterpolatedSql.Dapper.
Relies on string interpolation for SQL, so syntax errors or mismatches in SQL text aren't caught at compile-time, unlike type-safe ORM approaches, potentially leading to runtime issues.
Requires additional packages (e.g., InterpolatedSql.Dapper) for full integration with micro-ORMs, adding complexity to dependency management and setup compared to all-in-one solutions.