End-User Documentation

Load a Database Schema Snapshot

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

  1. Select a SQL Server profile such as DialectProfile.SqlServer2019.
  2. Call QueryLens.LoadDbSchemaFrom(connectionString) or the async overload.
  3. Check QueryLens.HasLoadedSchema to confirm that Level 3 is active.
  4. 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");

Related