Database

Query Configuration

Methods for specifying the SQL query, stored procedure, or table name that a database operation runs against.

Methods for specifying the SQL query, stored procedure, or table name that a database operation runs against.

WithSQLCommand sets an arbitrary SQL statement as the command source. WithStoredProcedure sets a stored procedure name to call. WithTableName sets a table name for simple SELECT queries - GPAL generates a basic SELECT automatically. WithRowCount limits the number of rows returned when using WithTableName. WithReadAs, WithCreateAs, WithUpdateAs, and WithDeleteAs set the SQL for each CRUD operation type when all four may be needed on a single database object.

Examples

GPAL Fluent: High-level fluent C# API

//WithTableName is the simplest query option - GPAL generates 'SELECT TOP n * FROM tableName'. Use WithSQLCommand or WithStoredProcedure when you need filtering, joins, or custom column selection.

// Query via SQL command GPAL.Database .WithConnectionString(connStr) .WithSQLCommand("SELECT TOP 100 * FROM Products ORDER BY Name") .Read .IntoGrid(out var products); // Query via table name (auto-generates SELECT) GPAL.Database .WithConnectionString(connStr) .WithTableName("Customers") .WithRowCount(500) .Read .IntoGrid(out var customers); // Call a stored procedure GPAL.Database .WithConnectionString(connStr) .WithStoredProcedure("usp_GetActiveOrders") .Read .IntoGrid(out var orders);