本文整理汇总了C#中FluentMigrator.Builders.Execute.PerformDBOperationExpression类的典型用法代码示例。如果您正苦于以下问题:C# PerformDBOperationExpression类的具体用法?C# PerformDBOperationExpression怎么用?C# PerformDBOperationExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PerformDBOperationExpression类属于FluentMigrator.Builders.Execute命名空间,在下文中一共展示了PerformDBOperationExpression类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanCreateAndDeleteTableUsingThePerformDBOperationExpressions
public void CanCreateAndDeleteTableUsingThePerformDBOperationExpressions()
{
var expression = new PerformDBOperationExpression
{
Operation = (connection, transaction) =>
{
// I know I could be using the expressions to create and delete this table,
// but really I just want to test whether I can execute some commands against the connection.
var command = connection.CreateCommand();
command.Transaction = transaction;
command.CommandText = "CREATE TABLE dbo.TestTable(TestTableID int NULL)";
command.ExecuteNonQuery();
var command2 = connection.CreateCommand();
command2.Transaction = transaction;
command2.CommandText = "DROP TABLE dbo.TestTable";
command2.ExecuteNonQuery();
}
};
ExecuteWithSqlServer(processor => processor.Process(expression), IntegrationTestOptions.SqlServer);
}
示例2: Process
public override void Process(PerformDBOperationExpression expression)
{
if (Connection.State != ConnectionState.Open) Connection.Open();
if (expression.Operation != null)
expression.Operation(Connection, null);
}
示例3: Process
public override void Process(PerformDBOperationExpression expression)
{
Announcer.Say("Performing DB Operation");
if (Options.PreviewOnly)
return;
if (Connection.State != ConnectionState.Open) Connection.Open();
if (expression.Operation != null)
expression.Operation(Connection, null);
}
示例4: Process
public override void Process(PerformDBOperationExpression expression)
{
Announcer.Say("Performing DB Operation");
if (Options.PreviewOnly)
return;
EnsureConnectionIsOpen();
if (expression.Operation != null)
expression.Operation(Connection, Transaction);
}
示例5: CallingProcessWithPerformDBOperationExpressionWhenInPreviewOnlyModeWillNotMakeDbChanges
public void CallingProcessWithPerformDBOperationExpressionWhenInPreviewOnlyModeWillNotMakeDbChanges()
{
var output = new StringWriter();
var connection = new SQLiteConnection(IntegrationTestOptions.SqlLite.ConnectionString);
var processor = new SqliteProcessor(
connection,
new SqliteGenerator(),
new TextWriterAnnouncer(output),
new ProcessorOptions { PreviewOnly = true },
new SqliteDbFactory());
bool tableExists;
try
{
var expression =
new PerformDBOperationExpression
{
Operation = (con, trans) =>
{
var command = con.CreateCommand();
command.CommandText = "CREATE TABLE ProcessTestTable (test int NULL) ";
command.Transaction = trans;
command.ExecuteNonQuery();
}
};
processor.Process(expression);
tableExists = processor.TableExists("", "ProcessTestTable");
}
finally
{
processor.RollbackTransaction();
}
tableExists.ShouldBeFalse();
output.ToString().ShouldBe(
@"/* Performing DB Operation */
");
}
示例6: CallingProcessWithPerformDBOperationExpressionWhenInPreviewOnlyModeWillNotMakeDbChanges
public void CallingProcessWithPerformDBOperationExpressionWhenInPreviewOnlyModeWillNotMakeDbChanges()
{
var output = new StringWriter();
var connection = new MySqlConnection(IntegrationTestOptions.MySql.ConnectionString);
var processor = SetupMySqlProcessorWithPreviewOnly(output, connection);
bool tableExists;
try
{
var expression =
new PerformDBOperationExpression
{
Operation = (con, trans) =>
{
var command = con.CreateCommand();
command.CommandText = "CREATE TABLE processtesttable (test int NULL) ";
command.Transaction = trans;
command.ExecuteNonQuery();
}
};
processor.Process(expression);
var com = connection.CreateCommand();
com.CommandText = "";
tableExists = processor.TableExists("", "processtesttable");
}
finally
{
processor.RollbackTransaction();
}
tableExists.ShouldBeFalse();
}
示例7: Process
public override void Process(PerformDBOperationExpression expression)
{
EnsureConnectionIsOpen();
if (expression.Operation != null)
expression.Operation(Connection, Transaction);
}
示例8: Process
public abstract void Process(PerformDBOperationExpression expression);
示例9: Process
public virtual void Process(PerformDBOperationExpression expression)
{
Processor.Process(expression);
}
示例10: WithConnection
public void WithConnection(Action<IDbConnection, IDbTransaction> operation)
{
var expression = new PerformDBOperationExpression { Operation = operation };
_context.Expressions.Add(expression);
}
示例11: Process
public override void Process(PerformDBOperationExpression expression)
{
throw new NotImplementedException();
}
示例12: ErrorIsReturnedWhenOperationIsNull
public void ErrorIsReturnedWhenOperationIsNull()
{
var expression = new PerformDBOperationExpression() { Operation = null };
var errors = ValidationHelper.CollectErrors(expression);
errors.ShouldContain(ErrorMessages.OperationCannotBeNull);
}