SQL Validation for .NET Teams
QueryLens
Validate raw SQL before it reaches production.
QueryLens gives .NET teams a fast way to validate hand-written SQL during tests, before runtime failures appear in production logs, CI pipelines, or customer environments. It is designed for teams that use Dapper, ADO.NET, repository patterns, or SQL registries and want stronger confidence without replacing their existing data-access approach.
The Problem
Applications that depend on hand-written SQL often detect mistakes too late. A missing column, invalid syntax, unsupported database-specific construct, or stale stored procedure name usually appears only during integration testing or in production execution.
QueryLens moves this feedback earlier by validating SQL where the application already defines it, without requiring the team to replace Dapper, ADO.NET, repository methods, or existing execution patterns.
Two Ways to Declare SQL
QueryLens supports direct statement construction and attribute-based discovery.
var query = new SqlQuery(
"SELECT customer_id, status FROM dbo.orders WHERE order_id = @Id",
validationParameters: new { Id = 42 });
Assert.True(query.IsValid, query.ErrorSummary);
public static class OrderQueries
{
[SqlQuery("SELECT customer_id, status FROM dbo.orders WHERE order_id = @Id")]
public static partial string GetById();
}
var result = QueryLens.ValidateAssembly(typeof(OrderQueries).Assembly);
Assert.True(result.IsValid, result.ErrorSummary);
Install from NuGet
Install QueryLens in the test project or validation host that will execute the SQL checks.
dotnet add package QueryLens
After installation, start with generic validation and then enable database-type-sensitive or schema-backed validation as needed.
Dapper-Compatible by Design
QueryLens statement wrappers can be passed directly to Dapper because they convert implicitly to string.
var sql = new SqlQuery(
"SELECT customer_id, status FROM dbo.orders WHERE order_id = @Id",
validationParameters: new { Id = 42 });
var order = await connection.QuerySingleOrDefaultAsync<OrderDto>(
sql,
new { Id = 42 });