Class DataFieldDef
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
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
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
ForeignKey
A string of the form
TableName.ColumnName
for creating a foreign key constraint on this field.
public string ForeignKey { get; set; }
Property Value
ForeignKeyConstraintName
When not null/empty indicates that this field has a foreign key constraint.
public string ForeignKeyConstraintName { get; set; }
Property Value
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
IsPrimaryKey
True when the field is a primary key
public bool IsPrimaryKey { get; set; }
Property Value
Length
Field length. Applicable to varchar fields only.
public int Length { get; set; }
Property Value
Name
A name unique among all instances of this type
public string Name { get; set; }
Property Value
Required
True when the field is NOT nullable
NOTE: when true then produces 'not null'
public bool Required { get; set; }
Property Value
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
TitleKey
Gets or sets a resource Key used in returning a localized version of Title
public string TitleKey { get; set; }
Property Value
Unique
When true indicates that the field has a unique constraint.
public bool Unique { get; set; }
Property Value
UniqueConstraintName
The unique constraint name to create when Unique is set to true.
public string UniqueConstraintName { get; set; }
Property Value
Methods
DataTypeToString()
Returns the string representation of a field data type.
public string DataTypeToString()
Returns
DataTypeToString(DataFieldType)
Returns the string representation of a field data type.
public static string DataTypeToString(DataFieldType Type)
Parameters
TypeDataFieldType
Returns
GetDataTypeDefText()
Returns the definition text for the data-type, e.g. @NVARCHAR(96)
public string GetDataTypeDefText()
Returns
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
IncludeNamebool
Returns
GetDefaultDefText()
Returns the definition text for the default constraint, e.g. '' or 0
public string GetDefaultDefText()
Returns
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
GetNullDefText()
Returns the definition text for the null/not null constraint, e.g. not null
public string GetNullDefText()
Returns
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
SetDefaultExpression(string)
Sets the value of a property and returns this instance.
public DataFieldDef SetDefaultExpression(string Value = null)
Parameters
Valuestring
Returns
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
Returns
SetLength(int)
Sets the value of a property and returns this instance.
public DataFieldDef SetLength(int Value = 0)
Parameters
Valueint
Returns
SetRequired(bool)
Sets the value of a property and returns this instance.
public DataFieldDef SetRequired(bool Value = true)
Parameters
Valuebool
Returns
SetTitleKey(string)
Sets the value of a property and returns this instance.
public DataFieldDef SetTitleKey(string Value = "")
Parameters
Valuestring
Returns
SetUnique(bool, string)
Sets the value of a property and returns this instance.
public DataFieldDef SetUnique(bool Value, string ConstraintName = "")
Parameters
Returns
ToString()
Returns a string representation of this instance.
public override string ToString()