Template syntax
Parsed when the command is created
static readonly QueryCommand SearchAlbums = new("SELECT AlbumId AS Id, Title FROM albums WHERE ArtistId = ?@artistId");
Conditional syntax is parsed into the command template at construction time.
Variable character
WHERE ArtistId = @artistId
A command can use another variable character.
static readonly QueryCommand SearchAlbums = new("SELECT AlbumId AS Id, Title FROM albums WHERE ArtistId = :artistId", ':');
var builder = SearchAlbums.StartBuilder();
builder.Use(':', "artistId", 7);
The application default can also be changed.
QueryFactory.DefaultVariableChar = ':';
Quoted text
SELECT '/*NotAMarker*/' AS Value
SELECT [/*Column*/], `?@value` FROM items
SELECT $$ /*NotAMarker*/ $$
Marker shaped text inside recognized quoted SQL remains ordinary text.
Line comment
SELECT AlbumId FROM albums
-- ?@ignored
WHERE ArtistId = @artistId
Conditional syntax inside a line comment is ignored.
Keep a block comment
SELECT AlbumId AS Id /*~ sent to the database */ FROM albums
/*~ marks a block comment that stays in generated SQL.
Template and generated SQL
SELECT AlbumId AS Id, Title FROM albums WHERE ArtistId = ?@artistId AND Title = ?@title
The template can contain conditional syntax that is not executable SQL before resolution. Each generated form still needs to be valid SQL for its target database.