本文整理汇总了C#中FluentMigrator.Runner.Processors.SqlServer.SqlServerProcessor.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# SqlServerProcessor.Execute方法的具体用法?C# SqlServerProcessor.Execute怎么用?C# SqlServerProcessor.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FluentMigrator.Runner.Processors.SqlServer.SqlServerProcessor
的用法示例。
在下文中一共展示了SqlServerProcessor.Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanReadLongViewDefinition
public void CanReadLongViewDefinition()
{
// Arrange
var create = new CreateTableExpression
{
TableName = "Foo",
Columns =
new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32 } }
};
IList<ViewDefinition> views;
var createSql = new StringBuilder();
createSql.Append("CREATE VIEW FooView As SELECT Id,");
createSql.Append("'");
createSql.Append(new string('A', 3000));
createSql.Append("'");
createSql.Append(" As LongText1,");
createSql.Append("'");
createSql.Append(new string('B', 3000));
createSql.Append("'");
createSql.Append(" As LongText2");
createSql.Append(" FROM Foo");
// Act
using (var connection = new SqlConnection(ConnectionString))
{
var processor = new SqlServerProcessor(connection, new SqlServer2005Generator(), new DebugAnnouncer(), new ProcessorOptions());
processor.Process(create);
Assert.IsTrue(processor.TableExists(string.Empty, create.TableName), "SqlServer");
processor.Execute(createSql.ToString());
var dumper = new SqlServerSchemaDumper(processor, new DebugAnnouncer());
views = dumper.ReadViewSchema();
processor.CommitTransaction();
}
// Assert
Assert.AreEqual(1, views.Count);
}
示例2: CreateViews
/// <summary>
/// Creates views in Oracle using the <see cref="ViewDefinition.CreateViewSql"/>
/// </summary>
/// <param name="view">The views to be created</param>
private void CreateViews(params ViewDefinition[] view)
{
using (var connection = new SqlConnection(_source.ConnectionString))
{
var processor = new SqlServerProcessor(connection, new SqlServer2005Generator(), new DebugAnnouncer(), new ProcessorOptions());
foreach (var viewDefinition in view)
{
processor.Execute(viewDefinition.CreateViewSql);
}
processor.CommitTransaction();
}
}
示例3: GetTableColumnColumns
/// <summary>
/// Creates a single column table using the spplied type and retruns its <see cref="ColumnDefinition"/>
/// </summary>
/// <param name="type">The Sql Server data type to apply to the column</param>
/// <returns>The translated <see cref="ColumnDefinition"/></returns>
private TableDefinition GetTableColumnColumns(string createSql, string name, params IMigrationExpression[] expresions)
{
IList<TableDefinition> tables;
// Act
using (var connection = new SqlConnection(ConnectionString))
{
var processor = new SqlServerProcessor(connection, new SqlServer2005Generator(), new DebugAnnouncer(), new ProcessorOptions());
if (!string.IsNullOrEmpty(createSql))
processor.Execute(createSql);
foreach (var expresion in expresions)
{
if (expresion is CreateTableExpression)
processor.Process((CreateTableExpression)expresion);
if (expresion is CreateIndexExpression)
processor.Process((CreateIndexExpression)expresion);
if (expresion is CreateForeignKeyExpression)
processor.Process((CreateForeignKeyExpression)expresion);
}
Assert.IsTrue(processor.TableExists(string.Empty, name), "SqlServer");
var dumper = new SqlServerSchemaDumper(processor, new DebugAnnouncer());
tables = dumper.ReadDbSchema();
processor.CommitTransaction();
}
if (!string.IsNullOrEmpty(createSql))
tables.Count.ShouldBe(1);
return tables.Where(t => t.Name == name).FirstOrDefault();
}
示例4: CanReadMultipleViews
public void CanReadMultipleViews()
{
// Arrange
var create = new CreateTableExpression
{
TableName = "Foo",
Columns =
new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32 } }
};
IList<ViewDefinition> views;
// Act
using (var connection = new SqlConnection(ConnectionString))
{
var processor = new SqlServerProcessor(connection, new SqlServer2005Generator(), new DebugAnnouncer(), new ProcessorOptions());
processor.Process(create);
Assert.IsTrue(processor.TableExists(string.Empty, create.TableName), "SqlServer");
processor.Execute("CREATE VIEW FooViewC AS SELECT Id FROM Foo");
processor.Execute("CREATE VIEW FooViewB AS SELECT Id FROM Foo");
processor.Execute("CREATE VIEW FooViewA AS SELECT Id FROM Foo");
var dumper = new SqlServerSchemaDumper(processor, new DebugAnnouncer());
views = dumper.ReadViewSchema();
processor.CommitTransaction();
}
// Assert
Assert.AreEqual(3, views.Count);
Assert.AreEqual("FooViewA", views[0].Name);
Assert.AreEqual("FooViewB", views[1].Name);
Assert.AreEqual("FooViewC", views[2].Name);
}