DatabaseTable

Classes > DataProvider > DatabaseTable

Represents a database table with its columns

public sealed record DatabaseTable : IEquatable<DatabaseTable>

Example

// Create a table definition with columns
var table = new DatabaseTable
{
    Schema = "dbo",
    Name = "Patients",
    Columns = new List<DatabaseColumn>
    {
        new DatabaseColumn { Name = "Id", SqlType = "uniqueidentifier", IsPrimaryKey = true },
        new DatabaseColumn { Name = "Name", SqlType = "nvarchar(100)" },
        new DatabaseColumn { Name = "DateOfBirth", SqlType = "date", IsNullable = true }
    }.AsReadOnly()
};

// Access computed column lists
var pkColumns = table.PrimaryKeyColumns;
var insertColumns = table.InsertableColumns;
var updateColumns = table.UpdateableColumns;

Properties

Schema

public string Schema { get; init; }

Table schema

Name

public string Name { get; init; }

Table name

Columns

public IReadOnlyList<DatabaseColumn> Columns { get; init; }

List of columns in the table

PrimaryKeyColumns

public IReadOnlyList<DatabaseColumn> PrimaryKeyColumns { get; }

Primary key columns

InsertableColumns

public IReadOnlyList<DatabaseColumn> InsertableColumns { get; }

Non-identity columns suitable for INSERT operations

UpdateableColumns

public IReadOnlyList<DatabaseColumn> UpdateableColumns { get; }

Non-primary key columns suitable for UPDATE operations