Table of Contents

Class DataFieldDef

Namespace
Tripous.Data
Assembly
Tripous.Data.dll

Database table field definition

public class DataFieldDef
Inheritance
DataFieldDef
Inherited Members
Extension Methods

Constructors

DataFieldDef()

Constructor

public DataFieldDef()

Properties

DataType

The data-type of the field. One of the DataFieldType constants.

public DataFieldType DataType { get; set; }

Property Value

DataFieldType

DecimalPart

Defines the Precision and Scale explicitly of a decimal field.

Used with Decimal_ only.

The user provides the Precision and Scale explicitly without parentheses..

Example: @DECIMAL_(10, 2) becomes decimal(10, 2)

public string DecimalPart { get; set; }

Property Value

string

DefaultExpression

The default expression, if any. E.g. 0, or ''. Defaults to null.

NOTE: e.g. produces default 0, or default ''

public string DefaultExpression { get; set; }

Property Value

string

ForeignKey

A string of the form 
TableName.ColumnName

for creating a foreign key constraint on this field.

public string ForeignKey { get; set; }

Property Value

string

ForeignKeyConstraintName

When not null/empty indicates that this field has a foreign key constraint.

public string ForeignKeyConstraintName { get; set; }

Property Value

string

Id

A GUID string. We need this in comparing two instances of DataTableDef for fields with the same Id but different Name, for column renaming.

public string Id { get; set; }

Property Value

string

IsPrimaryKey

True when the field is a primary key

public bool IsPrimaryKey { get; set; }

Property Value

bool

Length

Field length. Applicable to varchar fields only.

public int Length { get; set; }

Property Value

int

Name

A name unique among all instances of this type

public string Name { get; set; }

Property Value

string

Required

True when the field is NOT nullable

NOTE: when true then produces 'not null'

public bool Required { get; set; }

Property Value

bool

Title

Gets the Title of this instance, used for display purposes.

NOTE: The setter is fake. Do NOT use it.

public string Title { get; set; }

Property Value

string

TitleKey

Gets or sets a resource Key used in returning a localized version of Title

public string TitleKey { get; set; }

Property Value

string

Unique

When true indicates that the field has a unique constraint.

public bool Unique { get; set; }

Property Value

bool

UniqueConstraintName

The unique constraint name to create when Unique is set to true.

public string UniqueConstraintName { get; set; }

Property Value

string

Methods

DataTypeToString()

Returns the string representation of a field data type.

public string DataTypeToString()

Returns

string

DataTypeToString(DataFieldType)

Returns the string representation of a field data type.

public static string DataTypeToString(DataFieldType Type)

Parameters

Type DataFieldType

Returns

string

GetDataTypeDefText()

Returns the definition text for the data-type, e.g. @NVARCHAR(96)

public string GetDataTypeDefText()

Returns

string

GetDefText(bool)

Returns the field definition text.

WARNING: The returned text must be passed through ReplaceDataTypePlaceholders(string) method, for the final result.

public string GetDefText(bool IncludeName)

Parameters

IncludeName bool

Returns

string

GetDefaultDefText()

Returns the definition text for the default constraint, e.g. '' or 0

public string GetDefaultDefText()

Returns

string

GetForeignKeyConstraintDefText()

Returns the definition text of the foreign key constraint, if defined, else empty string.

CAUTION: For use with a CREATE TABLE statement only.

NOTE: All databases support foreign key constraint in the CREATE TABLE statement.

public string GetForeignKeyConstraintDefText()

Returns

string

GetNullDefText()

Returns the definition text for the null/not null constraint, e.g. not null

public string GetNullDefText()

Returns

string

GetUniqueConstraintDefText()

Returns the definition text of the unique constraint, if defined, else empty string.

CAUTION: For use with a CREATE TABLE statement only.

NOTE: All databases support unique constraint in the CREATE TABLE statement.

public string GetUniqueConstraintDefText()

Returns

string

SetDefaultExpression(string)

Sets the value of a property and returns this instance.

public DataFieldDef SetDefaultExpression(string Value = null)

Parameters

Value string

Returns

DataFieldDef

SetForeignKey(string, string)

Defines a foreign key upon this field and a foreign table and field specified by string of the form 
TableName.ColumnName

. Returns this.

public DataFieldDef SetForeignKey(string Value, string ConstraintName = "")

Parameters

Value string
ConstraintName string

Returns

DataFieldDef

SetLength(int)

Sets the value of a property and returns this instance.

public DataFieldDef SetLength(int Value = 0)

Parameters

Value int

Returns

DataFieldDef

SetRequired(bool)

Sets the value of a property and returns this instance.

public DataFieldDef SetRequired(bool Value = true)

Parameters

Value bool

Returns

DataFieldDef

SetTitleKey(string)

Sets the value of a property and returns this instance.

public DataFieldDef SetTitleKey(string Value = "")

Parameters

Value string

Returns

DataFieldDef

SetUnique(bool, string)

Sets the value of a property and returns this instance.

public DataFieldDef SetUnique(bool Value, string ConstraintName = "")

Parameters

Value bool
ConstraintName string

Returns

DataFieldDef

ToString()

Returns a string representation of this instance.

public override string ToString()

Returns

string