Database

Connection Configuration

WithConnectionString sets the full ADO.NET connection string directly. Alternatively, GPAL can construct a connection string from components: WithServerName for the SQL Server instance, WithDatabaseName for the database, and optionally WithUsername and WithPassword for SQL Server authentication (omit for Windows authentication). WithDatabaseType specifies the database engine - currently SQL Server is the supported type.

NOTE

If WithConnectionString is provided, the component settings (server, database, username, password) are ignored. Use WithConnectionString when you already have a connection string from your app config. Use the component methods when building the connection string programmatically.

Examples

GPAL Fluent: High-level fluent C# API

//ToGPALObject() returns the IGPALDatabase interface. Store the result and pass it to other GPAL methods (Converter, Logger, Browser FillInFrom) that accept a database parameter.

// Connect via full connection string

var db = GPAL.Database

.WithConnectionString("Server=myserver;Database=mydb;Trusted_Connection=True;")

.ToGPALObject();


// Connect via components (SQL auth)

var db2 = GPAL.Database

.WithServerName("myserver")

.WithDatabaseName("mydb")

.WithUsername("sa")

.WithPassword("secret")

.ToGPALObject();


// Connect via components (Windows auth - no username/password)

var db3 = GPAL.Database

.WithServerName("myserver")

.WithDatabaseName("mydb")

.ToGPALObject();

💬 Ask GPAL