当前位置: 首页>>代码示例>>C#>>正文


C# ITransaction.AddUniqueKey方法代码示例

本文整理汇总了C#中ITransaction.AddUniqueKey方法的典型用法代码示例。如果您正苦于以下问题:C# ITransaction.AddUniqueKey方法的具体用法?C# ITransaction.AddUniqueKey怎么用?C# ITransaction.AddUniqueKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITransaction的用法示例。


在下文中一共展示了ITransaction.AddUniqueKey方法的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");
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:48,代码来源:SystemSchema.cs


注:本文中的ITransaction.AddUniqueKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。