本文整理汇总了C#中IQuery.AddPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.AddPrimaryKey方法的具体用法?C# IQuery.AddPrimaryKey怎么用?C# IQuery.AddPrimaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQuery
的用法示例。
在下文中一共展示了IQuery.AddPrimaryKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTestView
private void CreateTestView(IQuery query)
{
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()));
query.CreateTable(tableInfo1);
query.AddPrimaryKey(tn1, "id");
var exp = SqlExpression.Parse("SELECT * FROM APP.test_table1");
query.ExecuteCreateView("APP.test_view1", (SqlQueryExpression) exp);
}
示例2: CreateTestTable
private void CreateTestTable(IQuery query)
{
var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table"));
var idColumn = tableInfo.AddColumn("id", PrimitiveTypes.Integer());
idColumn.DefaultExpression = SqlExpression.FunctionCall("UNIQUEKEY",
new SqlExpression[] { SqlExpression.Constant(tableInfo.TableName.FullName) });
tableInfo.AddColumn("first_name", PrimitiveTypes.String());
tableInfo.AddColumn("last_name", PrimitiveTypes.String());
tableInfo.AddColumn("birth_date", PrimitiveTypes.DateTime(), false);
tableInfo.AddColumn("active", PrimitiveTypes.Boolean());
query.CreateTable(tableInfo);
query.AddPrimaryKey(tableInfo.TableName, "id", "PK_TEST_TABLE");
}
示例3: CreateTables
private void CreateTables(IQuery query, string testsName)
{
var columns = new List<SqlTableColumn> {
new SqlTableColumn("id", PrimitiveTypes.Integer()),
new SqlTableColumn("name", PrimitiveTypes.String())
};
if (testsName.Equals("NotNullColumnViolation"))
columns.Add(new SqlTableColumn("age", PrimitiveTypes.Integer()) {
IsNotNull = true
});
query.CreateTable(new ObjectName("a"), columns.ToArray());
query.AddPrimaryKey(new ObjectName("a"), new []{"id"});
query.AddUniqueKey(new ObjectName("a"), new[] {"name"});
query.CreateTable(new ObjectName("b"), new SqlTableColumn("id", PrimitiveTypes.Integer()),
new SqlTableColumn("other_id", PrimitiveTypes.Integer()));
query.AddPrimaryKey(new ObjectName("b"), new[] {"id"});
query.AddForeignKey(new ObjectName("b"), new[] {"other_id"}, new ObjectName("a"), new[] {"id"},
ForeignKeyAction.Cascade, ForeignKeyAction.NoAction);
}
示例4: CreateTestTables
private void CreateTestTables(IQuery 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);
}