Load a Database Schema Snapshot
Loading a schema snapshot activates Level 3 validation so QueryLens can verify tables, columns, procedures, and write restrictions against real metadata.
Prerequisites
- Set a non-generic SQL Server dialect profile before loading the schema
- Load the schema before the runtime freezes
- Provide a connection string with permissions to read schema metadata
Steps
- Select a SQL Server profile such as
DialectProfile.SqlServer2019. - Call
QueryLens.LoadDbSchemaFrom(connectionString)or the async overload. - Check
QueryLens.HasLoadedSchemato confirm that Level 3 is active. - Validate statements and review any new schema-backed diagnostics.
Example
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");