Class ForeignKey
Represents a foreign key constraint in a database schema. This class provides details about the referenced table, the columns involved, and the actions to take on update or delete.
public class ForeignKey : Key, IVisitorAcceptor, ICheckable
- Inheritance
-
ForeignKey
- Implements
- Inherited Members
Constructors
ForeignKey(Table, string, IEnumerable<string>, string, string, string[], ForeignKeyRule, ForeignKeyRule)
Initializes a new instance of the ForeignKey class.
public ForeignKey(Table table, string name, IEnumerable<string> columnNames, string relatedName, string relatedOwner, string[] relatedColumns, ForeignKeyRule updateRule, ForeignKeyRule deleteRule)
Parameters
tableTableThe table that owns the foreign key.
namestringThe name of the foreign key constraint.
columnNamesIEnumerable<string>The names of the columns that make up the foreign key.
relatedNamestringThe name of the referenced table.
relatedOwnerstringThe owner of the referenced table.
relatedColumnsstring[]The names of the columns in the referenced table.
updateRuleForeignKeyRuleThe action to take on update.
deleteRuleForeignKeyRuleThe action to take on delete.
Properties
DeleteRule
Gets the action to take on delete.
public ForeignKeyRule DeleteRule { get; }
Property Value
RelatedColumnNames
Gets the names of the columns in the referenced table.
public string[] RelatedColumnNames { get; }
Property Value
- string[]
RelatedTable
Gets a reference to the referenced table if loaded in the imported database schema, otherwise null.
public Table RelatedTable { get; }
Property Value
RelatedTableFullName
Gets the fully qualified name of the referenced table.
public string RelatedTableFullName { get; }
Property Value
RelatedTableName
Gets the name of the referenced table.
public string RelatedTableName { get; }
Property Value
RelatedTableOwner
Gets the owner of the referenced table.
public string RelatedTableOwner { get; }
Property Value
UpdateRule
Gets the action to take on update.
public ForeignKeyRule UpdateRule { get; }
Property Value
Methods
AcceptVisitor(IVisitor)
Accepts a visitor, allowing it to perform operations on the implementing class. The visitor will typically have specific methods for handling different types of elements in the object structure.
public override void AcceptVisitor(IVisitor visitor)
Parameters
visitorIVisitorThe visitor instance that will perform operations on the implementing class.
GetRelatedColumn(int)
Retrieves the related column based on the specified index in the foreign key relationship.
public Column GetRelatedColumn(int i)
Parameters
iintThe zero-based index of the related column in the foreign key relationship.