本文整理汇总了C#中ITransaction.AddForeignKey方法的典型用法代码示例。如果您正苦于以下问题:C# ITransaction.AddForeignKey方法的具体用法?C# ITransaction.AddForeignKey怎么用?C# ITransaction.AddForeignKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITransaction
的用法示例。
在下文中一共展示了ITransaction.AddForeignKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public static void Setup(ITransaction transaction)
{
// -- Primary Keys --
// The 'id' columns are primary keys on all the system tables,
var idCol = new[] { "id" };
transaction.AddPrimaryKey(PrimaryKeyInfoTableName, idCol, "SYSTEM_PK_PK");
transaction.AddPrimaryKey(ForeignKeyInfoTableName, idCol, "SYSTEM_FK_PK");
transaction.AddPrimaryKey(UniqueKeyInfoTableName, idCol, "SYSTEM_UNIQUE_PK");
transaction.AddPrimaryKey(CheckInfoTableName, idCol, "SYSTEM_CHECK_PK");
transaction.AddPrimaryKey(SchemaInfoTableName, idCol, "SYSTEM_SCHEMA_PK");
// -- Foreign Keys --
// Create the foreign key references,
var fkCol = new string[1];
var fkRefCol = new[] { "id" };
fkCol[0] = "pk_id";
transaction.AddForeignKey(PrimaryKeyColumnsTableName, fkCol, PrimaryKeyInfoTableName, fkRefCol, "SYSTEM_PK_FK");
fkCol[0] = "fk_id";
transaction.AddForeignKey(ForeignKeyColumnsTableName, fkCol, ForeignKeyInfoTableName, fkRefCol, "SYSTEM_FK_FK");
fkCol[0] = "un_id";
transaction.AddForeignKey(UniqueKeyColumnsTableName, fkCol, UniqueKeyInfoTableName, fkRefCol, "SYSTEM_UNIQUE_FK");
// pkey_info 'schema', 'table' column is a unique set,
// (You are only allowed one primary key per table).
var columns = new[] { "schema", "table" };
transaction.AddUniqueKey(PrimaryKeyInfoTableName, columns, "SYSTEM_PKEY_ST_UNIQUE");
// schema_info 'name' column is a unique column,
columns = new String[] { "name" };
transaction.AddUniqueKey(SchemaInfoTableName, columns, "SYSTEM_SCHEMA_UNIQUE");
// columns = new String[] { "name" };
columns = new String[] { "name", "schema" };
// pkey_info 'name' column is a unique column,
transaction.AddUniqueKey(PrimaryKeyInfoTableName, columns, "SYSTEM_PKEY_UNIQUE");
// fkey_info 'name' column is a unique column,
transaction.AddUniqueKey(ForeignKeyInfoTableName, columns, "SYSTEM_FKEY_UNIQUE");
// unique_info 'name' column is a unique column,
transaction.AddUniqueKey(UniqueKeyInfoTableName, columns, "SYSTEM_UNIQUE_UNIQUE");
// check_info 'name' column is a unique column,
transaction.AddUniqueKey(CheckInfoTableName, columns, "SYSTEM_CHECK_UNIQUE");
}