Application Model Validation
This stage adds schema-backed validation. QueryLens loads a database snapshot and validates table names, column names, stored procedures, and schema-backed write rules against that snapshot.
What You Get
- Missing table detection
- Missing column detection
- Missing stored procedure detection
- Identity, computed-column, and required-column checks
Minimal SQL Server Example
QueryLens.Reset();
QueryLens.Dialect = DialectProfile.SqlServer2019;
QueryLens.LoadDbSchemaFrom(connectionString);
Assert.True(QueryLens.HasLoadedSchema);
var query = new SqlQuery("SELECT id, missing_column FROM dbo.customers");
Assert.False(query.IsValid);
Assert.Contains(query.Errors, issue => issue.Code == "QL0011");
Important Note
Schema-backed validation is currently implemented for SQL Server profiles. PostgreSQL and Oracle currently support database-type-sensitive validation, but not schema loading.
More Examples
var missingTable = new SqlQuery("SELECT * FROM dbo.missing_orders");
Assert.Contains(missingTable.Errors, issue => issue.Code == "QL0010");
var missingProcedure = new SqlStoredProc("EXEC dbo.usp_missing_orders @BatchId = @BatchId");
Assert.Contains(missingProcedure.Errors, issue => issue.Code == "QL0012");