Database

Column Definitions

The column definition methods (WithIntegerColumn, WithVarCharColumn, WithDecimalColumn, etc.) are used when GPAL is generating CREATE TABLE statements or defining column metadata for an operation. Each method accepts a column name and returns the database object for chaining. WithColumnLength sets the maximum length for character columns. WithColumnPrecision and WithColumnScale set precision and scale for decimal and numeric columns. Supported column types are Integer, Decimal, Float, Money, Char, NChar, VarChar, NVarChar, Text, NText, Datetime, Time, Timestamp, Image, and structured table columns. There is no dedicated boolean/bit type - the recommended pattern is a nullable Datetime column, where NULL means false and a set date means true.

Examples

GPAL Fluent: High-level fluent C# API

//Column definition methods are chained in the order the columns should appear in the schema. WithColumnLength, WithColumnPrecision, and WithColumnScale apply to the most recently defined column.

// Define a table schema

GPAL.Database

.WithConnectionString(connStr)

.WithIntegerColumn("Id")

.WithNVarCharColumn("Name")

.WithColumnLength(100)

.WithNVarCharColumn("Email")

.WithColumnLength(255)

.WithDecimalColumn("Balance")

.WithColumnPrecision(18)

.WithColumnScale(2)

.Create

.Execute(out _);

💬 Ask GPAL