End-User Documentation

Quick Start

Quick Start

This is the fastest way to see QueryLens working with basic syntax validation before you add database-specific or schema-backed validation.

Minimal SqlQuery Example

using QueryLens.Statements;

var query = new SqlQuery("SELECT id, name FROM customers");
Assert.True(query.IsValid);

Minimal [SqlQuery] Attribute Example

using QueryLens;
using QueryLens.Discovery;

public static class CustomerQueries
{
    [SqlQuery]
    public static string GetAll => "SELECT id, name FROM customers";
}

var result = QueryLens.ValidateAssembly(typeof(CustomerQueries).Assembly);
Assert.True(result.AllValid, result.Summary);

Valid Example

var query = new SqlQuery("SELECT id, name FROM customers");

Assert.True(query.IsValid);
Assert.Empty(query.Errors);
Assert.Empty(query.Warnings);
Assert.Equal("No issues found.", query.ErrorSummary);

Invalid Example

var query = new SqlQuery("SELECT FROM customers");

Assert.False(query.IsValid);
Assert.Contains(query.Errors, issue => issue.Code == "QL0001");
Assert.NotEmpty(query.ErrorSummary);

What To Inspect

  • IsValid for a fast pass/fail assertion
  • Errors for blocking problems
  • Warnings for risky but non-fatal issues
  • ErrorSummary for a readable failure message

Related