QueryLens Manual
Validate raw SQL at test time, not runtime.
QueryLens gives Dapper, ADO.NET, and query-registry codebases a lightweight way to catch broken SQL before production code executes it. The main workflow is small on purpose: wrap SQL in a statement type, optionally choose a DialectProfile, optionally load a schema snapshot, then assert IsValid and inspect diagnostics.
Start Here
- Product overview: QueryLens
- New to QueryLens: What QueryLens Is
- Ready to install: Install QueryLens
- Start with Quick Start
- Continue with Database Type Validation
- Continue with Application Model Validation
- Choosing strictness: Choose a Validation Level
- Debugging a failure: Query Fails Validation
- Looking up APIs or diagnostics: QueryLens Facade API
Validation Levels
| Level | Trigger | What it adds |
|---|---|---|
| 1 | Default | Permissive, cross-dialect structural SQL validation |
| 2 | QueryLens.Dialect = ... |
Dialect-specific syntax, reserved words, functions, and version checks |
| 3 | QueryLens.LoadDbSchemaFrom(...) |
Table, column, procedure, and schema-backed write validation |
Compact Example
var query = new SqlQuery("SELECT customer_id, status FROM dbo.orders WHERE order_id = @Id");
Assert.True(query.IsValid, query.ErrorSummary);
Main Paths
- Learn the mental model: Validation Levels
- Follow task-based setup guides: Add QueryLens to an Existing Test Project
- Jump straight to APIs and diagnostics: Reference
- Solve common issues: Troubleshooting
- Check upgrade guidance: Migration