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


C# IQueryContext.AddPrimaryKey方法代码示例

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


在下文中一共展示了IQueryContext.AddPrimaryKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateTestTables

        private void CreateTestTables(IQueryContext context)
        {
            var tn1 = ObjectName.Parse("APP.test_table1");
            var tableInfo1 = new TableInfo(tn1);
            tableInfo1.AddColumn(new ColumnInfo("id", PrimitiveTypes.Integer()));
            tableInfo1.AddColumn(new ColumnInfo("name", PrimitiveTypes.String()));
            tableInfo1.AddColumn(new ColumnInfo("date", PrimitiveTypes.DateTime()));
            context.CreateTable(tableInfo1);
            context.AddPrimaryKey(tn1, "id");

            var tn2 = ObjectName.Parse("APP.test_table2");
            var tableInfo2 = new TableInfo(tn2);
            tableInfo2.AddColumn(new ColumnInfo("id", PrimitiveTypes.Integer()));
            tableInfo2.AddColumn(new ColumnInfo("other_id", PrimitiveTypes.Integer()));
            tableInfo2.AddColumn(new ColumnInfo("count", PrimitiveTypes.Integer()));
            context.CreateTable(tableInfo2);
            context.AddPrimaryKey(tn2, "id");
            context.AddForeignKey(tn2, new []{"other_id"}, tn1, new []{"id"}, ForeignKeyAction.Cascade, ForeignKeyAction.Cascade, null);
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:19,代码来源:DropTableTests.cs

示例2: CreateTestTable

        private void CreateTestTable(IQueryContext context)
        {
            var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table"));
            var idColumn = tableInfo.AddColumn("id", PrimitiveTypes.Integer());
            idColumn.DefaultExpression = SqlExpression.FunctionCall("UNIQUE_KEY",
                new SqlExpression[] { SqlExpression.Reference(tableInfo.TableName) });
            tableInfo.AddColumn("first_name", PrimitiveTypes.String());
            tableInfo.AddColumn("last_name", PrimitiveTypes.String());
            tableInfo.AddColumn("birth_date", PrimitiveTypes.DateTime());
            tableInfo.AddColumn("active", PrimitiveTypes.Boolean());

            context.CreateTable(tableInfo);
            context.AddPrimaryKey(tableInfo.TableName, "id", "PK_TEST_TABLE");
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:14,代码来源:SelectStatementTests.cs

示例3: CreateSecurityTables

        private static void CreateSecurityTables(IQueryContext context)
        {
            var tableInfo = new TableInfo(UserTableName);
            tableInfo.AddColumn("name", PrimitiveTypes.String());
            // TODO: User table must be completed ...
            tableInfo = tableInfo.AsReadOnly();
            context.CreateTable(tableInfo);

            context.AddPrimaryKey(UserTableName, new []{"name"}, "SYSTEM_USER_PK");

            tableInfo = new TableInfo(PasswordTableName);
            tableInfo.AddColumn("user", PrimitiveTypes.String());
            tableInfo.AddColumn("type", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("hash", PrimitiveTypes.String());
            tableInfo.AddColumn("salt", PrimitiveTypes.String());
            tableInfo.AddColumn("hash_algorithm", PrimitiveTypes.String());
            tableInfo = tableInfo.AsReadOnly();
            context.CreateTable(tableInfo);

            tableInfo = new TableInfo(UserPrivilegesTableName);
            tableInfo.AddColumn("user", PrimitiveTypes.String());
            tableInfo.AddColumn("group", PrimitiveTypes.String());
            tableInfo = tableInfo.AsReadOnly();
            context.CreateTable(tableInfo);

            tableInfo = new TableInfo(UserConnectPrivilegesTableName);
            tableInfo.AddColumn("user", PrimitiveTypes.String());
            tableInfo.AddColumn("protocol", PrimitiveTypes.String());
            tableInfo.AddColumn("host", PrimitiveTypes.String());
            tableInfo.AddColumn("access", PrimitiveTypes.Boolean());
            tableInfo = tableInfo.AsReadOnly();
            context.CreateTable(tableInfo);

            tableInfo = new TableInfo(UserGrantsTableName);
            tableInfo.AddColumn("priv_bit", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("object", PrimitiveTypes.Numeric());
            tableInfo.AddColumn("name", PrimitiveTypes.String());
            tableInfo.AddColumn("user", PrimitiveTypes.String());
            tableInfo.AddColumn("grant_option", PrimitiveTypes.Boolean());
            tableInfo.AddColumn("granter", PrimitiveTypes.String());
            tableInfo = tableInfo.AsReadOnly();
            context.CreateTable(tableInfo);

            var fkCol = new[] {"user"};
            var refCol = new[] {"name"};
            const ForeignKeyAction onUpdate = ForeignKeyAction.NoAction;
            const ForeignKeyAction onDelete = ForeignKeyAction.Cascade;
            context.AddForeignKey(PasswordTableName, fkCol, UserTableName, refCol, onDelete, onUpdate, "USER_PASSWORD_FK");
            context.AddForeignKey(UserPrivilegesTableName, fkCol, UserTableName, refCol, onDelete, onUpdate, "USER_PRIV_FK");
            context.AddForeignKey(UserConnectPrivilegesTableName, fkCol, UserTableName, refCol, onDelete, onUpdate, "USER_CONNPRIV_FK");
            context.AddForeignKey(UserGrantsTableName, fkCol, UserTableName, refCol, onDelete, onUpdate, "USER_GRANTS_FK");
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:52,代码来源:SystemSchema.cs


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