Validate a Simple SELECT Query
A SqlQuery is the smallest useful entry point: create it, inspect IsValid, and review the resulting diagnostics when validation fails.
Steps
- Construct a
SqlQuerywith your raw SQL text. - Read
IsValidfor a quick yes-or-no assertion. - If it fails, inspect
Errors,Warnings, orErrorSummary. - Promote common failures into dedicated tests so regressions stay easy to diagnose.
Example
var validQuery = new SqlQuery("SELECT id, name FROM customers");
Assert.True(validQuery.IsValid);
var invalidQuery = new SqlQuery("SELECT FROM customers");
Assert.False(invalidQuery.IsValid);
Assert.Contains(invalidQuery.Errors, issue => issue.Code == "QL0001");