End-User Documentation

Add QueryLens to an Existing Test Project

Add QueryLens to an Existing Test Project

The safest rollout is incremental: start with a few high-value statements in Level 1, then introduce a dialect profile, then add a schema snapshot when the suite is stable.

Recommended Rollout

  1. Install the package with dotnet add package QueryLens.
  2. Pick one global test setup location and set QueryLens.Dialect there if you want Level 2 validation.
  3. Add a few focused assertions around important queries using IsValid, Errors, or ErrorSummary.
  4. When you are ready for Level 3, load the schema snapshot before any validation occurs.
  5. Call QueryLens.Reset() between suites only when you intentionally need to reconfigure the runtime.

Common Mistakes

  • Setting QueryLens.Dialect after a previous test has already triggered validation
  • Loading schema with the default generic profile still selected
  • Mixing unrelated configuration patterns across test classes instead of one shared fixture

Example

public sealed class QueryLensFixture
{
    public QueryLensFixture()
    {
        QueryLens.Reset();
        QueryLens.Dialect = DialectProfile.SqlServer2019;
    }
}

Related