End-User Documentation

First Schema-Backed Validation

First Schema-Backed Validation

This is the first end-to-end Level 3 flow: choose a SQL Server profile, load the schema snapshot, then validate a query against real metadata.

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");

What HasLoadedSchema Means

QueryLens.HasLoadedSchema tells you the runtime currently has a schema snapshot loaded, which activates Level 3 validation.

Important Note

Schema loading currently requires a non-generic dialect and is currently implemented for SQL Server profiles.

Related