本文整理汇总了C#中FluentMigrator.Expressions.CreateForeignKeyExpression类的典型用法代码示例。如果您正苦于以下问题:C# CreateForeignKeyExpression类的具体用法?C# CreateForeignKeyExpression怎么用?C# CreateForeignKeyExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateForeignKeyExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了CreateForeignKeyExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetCreateForeignKeyExpression
public static CreateForeignKeyExpression GetCreateForeignKeyExpression()
{
var expression = new CreateForeignKeyExpression();
expression.ForeignKey.Name = "FK_Test";
expression.ForeignKey.PrimaryTable = TestTableName2;
expression.ForeignKey.ForeignTable = TestTableName1;
expression.ForeignKey.PrimaryColumns = new[] { TestColumnName2 };
expression.ForeignKey.ForeignColumns = new[] { TestColumnName1 };
return expression;
}
开发者ID:hazzik,项目名称:fluentmigrator,代码行数:11,代码来源:GeneratorTestHelper.cs
示例2: CanCreateForeignKey
public void CanCreateForeignKey()
{
var expression = new CreateForeignKeyExpression();
expression.ForeignKey.Name = "FK_Test";
expression.ForeignKey.PrimaryTable = "TestPrimaryTable";
expression.ForeignKey.ForeignTable = "TestForeignTable";
expression.ForeignKey.PrimaryColumns = new[] { "Column1", "Column2" };
expression.ForeignKey.ForeignColumns = new[] { "Column3", "Column4" };
string sql = generator.Generate(expression);
sql.ShouldBe("ALTER TABLE TestForeignTable ADD CONSTRAINT FK_Test FOREIGN KEY (Column3,Column4) REFERENCES TestPrimaryTable (Column1,Column2)");
}
开发者ID:nats,项目名称:fluentmigrator,代码行数:12,代码来源:OracleGeneratorTests.cs
示例3: CanCreateForeignKey
public void CanCreateForeignKey()
{
var expression = new CreateForeignKeyExpression();
expression.ForeignKey.Name = "FK_Test";
expression.ForeignKey.PrimaryTable = "TestPrimaryTable";
expression.ForeignKey.ForeignTable = "TestForeignTable";
expression.ForeignKey.PrimaryColumns = new[] { "Column1", "Column2" };
expression.ForeignKey.ForeignColumns = new[] { "Column3", "Column4" };
var sql = generator.Generate(expression);
sql.ShouldBe(
"ALTER TABLE [TestForeignTable] ADD CONSTRAINT FK_Test FOREIGN KEY ([Column3],[Column4]) REFERENCES [TestPrimaryTable] ([Column1],[Column2])");
}
开发者ID:briandonahue,项目名称:fluentmigrator,代码行数:13,代码来源:SqlServer2000GeneratorTests.cs
示例4: Generate
public override string Generate(CreateForeignKeyExpression expression)
{
string primaryColumns = GetColumnList(expression.ForeignKey.PrimaryColumns);
string foreignColumns = GetColumnList(expression.ForeignKey.ForeignColumns);
string sql = "ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4})";
return String.Format(sql,
expression.ForeignKey.ForeignTable,
expression.ForeignKey.Name,
foreignColumns,
expression.ForeignKey.PrimaryTable,
primaryColumns
);
}
开发者ID:jtreuting,项目名称:fluentmigrator,代码行数:15,代码来源:OracleGenerator.cs
示例5: ToStringIsDescriptive
public void ToStringIsDescriptive()
{
var sql = new CreateForeignKeyExpression
{
ForeignKey = new ForeignKeyDefinition
{
ForeignColumns = new Collection<string> { "User_id" },
ForeignTable = "UserRoles",
PrimaryColumns = new Collection<string> { "Id" },
PrimaryTable = "User",
Name = "FK"
}
}.ToString();
sql.ShouldBe("CreateForeignKey FK UserRoles(User_id) User(Id)");
}
开发者ID:paulbatum,项目名称:fluentmigrator,代码行数:15,代码来源:CreateForeignKeyExpressionTests.cs
示例6: Generate
public override string Generate(CreateForeignKeyExpression expression)
{
var primaryColumns = GetColumnList(expression.ForeignKey.PrimaryColumns);
var foreignColumns = GetColumnList(expression.ForeignKey.ForeignColumns);
const string sql = "ALTER TABLE {0}[{1}] ADD CONSTRAINT {2} FOREIGN KEY ({3}) REFERENCES {4}[{5}] ({6})";
return string.Format(sql,
FormatSchema(expression.ForeignKey.ForeignTableSchema),
expression.ForeignKey.ForeignTable,
expression.ForeignKey.Name,
foreignColumns,
FormatSchema(expression.ForeignKey.PrimaryTableSchema),
expression.ForeignKey.PrimaryTable,
primaryColumns
);
}
开发者ID:briandonahue,项目名称:fluentmigrator,代码行数:17,代码来源:SqlServer2000Generator.cs
示例7: Generate
public override string Generate(CreateForeignKeyExpression expression)
{
string primaryColumns = GetColumnList(expression.ForeignKey.PrimaryColumns);
string foreignColumns = GetColumnList(expression.ForeignKey.ForeignColumns);
string sql = "ALTER TABLE `{0}` ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4}){5}{6}";
return String.Format(sql,
expression.ForeignKey.ForeignTable,
expression.ForeignKey.Name,
foreignColumns,
expression.ForeignKey.PrimaryTable,
primaryColumns,
FormatCascade("DELETE", expression.ForeignKey.OnDelete),
FormatCascade("UPDATE", expression.ForeignKey.OnUpdate)
);
}
开发者ID:Ang3lFir3,项目名称:fluentmigrator,代码行数:17,代码来源:MySqlGenerator.cs
示例8: Generate
public override string Generate(CreateForeignKeyExpression expression)
{
var primaryColumns = GetColumnList(expression.ForeignKey.PrimaryColumns);
var foreignColumns = GetColumnList(expression.ForeignKey.ForeignColumns);
const string sql = "ALTER TABLE {0}.{1} ADD CONSTRAINT {2} FOREIGN KEY ({3}) REFERENCES {4}.{5} ({6}){7}{8}";
return string.Format(sql,
Quoter.QuoteSchemaName(expression.ForeignKey.ForeignTableSchema),
Quoter.QuoteTableName(expression.ForeignKey.ForeignTable),
Quoter.Quote(expression.ForeignKey.Name),
foreignColumns,
Quoter.QuoteSchemaName(expression.ForeignKey.PrimaryTableSchema),
Quoter.QuoteTableName(expression.ForeignKey.PrimaryTable),
primaryColumns,
FormatCascade("DELETE", expression.ForeignKey.OnDelete),
FormatCascade("UPDATE", expression.ForeignKey.OnUpdate)
);
}
开发者ID:VSoftTechnologies,项目名称:fluentmigrator,代码行数:19,代码来源:PostgresGenerator.cs
示例9: Truncate
public void Truncate(CreateForeignKeyExpression expression)
{
Truncate(expression.ForeignKey);
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:4,代码来源:FirebirdTruncator.cs
示例10: Generate
public override string Generate(CreateForeignKeyExpression expression)
{
return string.Format("{0};", base.Generate(expression));
}
开发者ID:SaltyDH,项目名称:fluentmigrator,代码行数:4,代码来源:HanaGenerator.cs
示例11: GenerateForeignKeyName
public virtual string GenerateForeignKeyName(CreateForeignKeyExpression expression)
{
return string.Format("FK_{0}_{1}", expression.ForeignKey.PrimaryTable.Substring(0, 5), expression.ForeignKey.ForeignTable.Substring(0, 5));
}
开发者ID:robertmircea,项目名称:fluentmigrator,代码行数:4,代码来源:GenericGenerator.cs
示例12: ForeignKey
public ICreateForeignKeyFromTableSyntax ForeignKey()
{
var expression = new CreateForeignKeyExpression();
_context.Expressions.Add(expression);
return new CreateForeignKeyExpressionBuilder(expression);
}
开发者ID:fire-eagle,项目名称:fluentmigrator,代码行数:6,代码来源:CreateExpressionRoot.cs
示例13: Generate
public override string Generate(CreateForeignKeyExpression expression)
{
return compatabilityMode.HandleCompatabilty("Forign keys are not supported in Sqlite");
}
开发者ID:robinvarg,项目名称:fluentmigrator,代码行数:4,代码来源:SqliteGenerator.cs
示例14: CanForeignKeyToUniqueColumn
public void CanForeignKeyToUniqueColumn()
{
// Arrange
var create = new CreateTableExpression
{
TableName = "Foo",
Columns = new[]{
new ColumnDefinition {Name = "Id", Type = DbType.Int32, IsPrimaryKey = true}
, new ColumnDefinition {Name = "Type", Type = DbType.Int32}
}
};
var index = new CreateIndexExpression
{
Index =
new IndexDefinition()
{
Name = "IDX_FooType",
TableName = "Foo",
IsUnique = true,
Columns = new List<IndexColumnDefinition> { new IndexColumnDefinition { Name = "Type" } }
}
};
var secondTable = new CreateTableExpression
{
TableName = "Bar",
Columns = new[]{
new ColumnDefinition {Name = "Id", Type = DbType.Int32, IsPrimaryKey = true}
, new ColumnDefinition {Name = "FooType", Type = DbType.Int32}
}
};
var foreignKey = new CreateForeignKeyExpression
{
ForeignKey =
new ForeignKeyDefinition()
{
Name = "FK_FooType",
ForeignTable = "Bar",
ForeignColumns = new [] { "FooType" },
PrimaryTable= "Foo",
PrimaryColumns = new[] { "Type" }
}
};
// Act
MigrateToOracleWithData(new List<IMigrationExpression> { create, index, secondTable, foreignKey }, 2);
// Assert
}
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:52,代码来源:SqlServerToOracleMigrationTests.cs
示例15: CallingOnUpdateSetsOnUpdateToSpecifiedRule
public void CallingOnUpdateSetsOnUpdateToSpecifiedRule(Rule rule)
{
var expression = new CreateForeignKeyExpression();
var builder = new CreateForeignKeyExpressionBuilder(expression);
builder.OnUpdate(rule);
Assert.That(expression.ForeignKey.OnUpdate, Is.EqualTo(rule));
Assert.That(expression.ForeignKey.OnDelete, Is.EqualTo(Rule.None));
}
开发者ID:guillaume86,项目名称:fluentmigrator,代码行数:8,代码来源:CreateForeignKeyExpressionBuilderTests.cs
示例16: Process
public virtual void Process(CreateForeignKeyExpression expression)
{
Process(Generator.Generate(expression));
}
开发者ID:Ang3lFir3,项目名称:fluentmigrator,代码行数:4,代码来源:ProcessorBase.cs
示例17: GetCreateForeignKeyExpression
public static CreateForeignKeyExpression GetCreateForeignKeyExpression()
{
var expression = new CreateForeignKeyExpression();
expression.ForeignKey.PrimaryTable = TestTableName2;
expression.ForeignKey.ForeignTable = TestTableName1;
expression.ForeignKey.PrimaryColumns = new[] { TestColumnName2 };
expression.ForeignKey.ForeignColumns = new[] { TestColumnName1 };
expression.ApplyConventions(new MigrationConventions());
return expression;
}
开发者ID:haf,项目名称:fluentmigrator,代码行数:11,代码来源:GeneratorTestHelper.cs
示例18: Generate
public abstract string Generate(CreateForeignKeyExpression expression);
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:1,代码来源:GeneratorBase.cs
示例19: Generate
public override string Generate(CreateForeignKeyExpression expression)
{
// Ignore foreign keys for SQLite
return "";
}
开发者ID:paulbatum,项目名称:fluentmigrator,代码行数:5,代码来源:SqliteGenerator.cs
示例20: CanCreateForeignKeyToDifferentSchema
public void CanCreateForeignKeyToDifferentSchema()
{
var expression = new CreateForeignKeyExpression();
expression.ForeignKey.Name = "FK_Test";
expression.ForeignKey.PrimaryTable = "TestPrimaryTable";
expression.ForeignKey.ForeignTable = "TestForeignTable";
expression.ForeignKey.PrimaryColumns = new[] { "Column1", "Column2" };
expression.ForeignKey.ForeignColumns = new[] { "Column3", "Column4" };
expression.ForeignKey.PrimaryTableSchema = "wibble";
string sql = generator.Generate(expression);
sql.ShouldBe("ALTER TABLE \"public\".\"TestForeignTable\" ADD CONSTRAINT \"FK_Test\" FOREIGN KEY (\"Column3\",\"Column4\") REFERENCES \"wibble\".\"TestPrimaryTable\" (\"Column1\",\"Column2\")");
}
开发者ID:timscott,项目名称:fluentmigrator,代码行数:13,代码来源:PostgresGeneratorTests.cs
注:本文中的FluentMigrator.Expressions.CreateForeignKeyExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论