本文整理汇总了C#中FluentMigrator.Expressions.DeleteDataExpression类的典型用法代码示例。如果您正苦于以下问题:C# DeleteDataExpression类的具体用法?C# DeleteDataExpression怎么用?C# DeleteDataExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeleteDataExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了DeleteDataExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteVersion
public void DeleteVersion(long version)
{
var expression = new DeleteDataExpression {TableName = VersionTableMetaData.TableName, SchemaName = VersionTableMetaData.SchemaName};
expression.Rows.Add(new DeletionDataDefinition
{
new KeyValuePair<string, object>(VersionTableMetaData.ColumnName, version)
});
expression.ExecuteWith(Processor);
}
示例2: Reverse
public IMigrationExpression Reverse()
{
var expression = new DeleteDataExpression
{
SchemaName = SchemaName,
TableName = TableName,
};
expression.Rows.AddRange(Rows);
return expression;
}
示例3: Reverse
public IMigrationExpression Reverse()
{
var expression = new DeleteDataExpression
{
SchemaName = SchemaName,
TableName = TableName
};
foreach (var row in Rows)
{
var dataDefinition = new DeletionDataDefinition();
dataDefinition.AddRange(row);
expression.Rows.Add(dataDefinition);
}
return expression;
}
示例4: CanDeleteAllData
public void CanDeleteAllData()
{
var expression = new DeleteDataExpression
{
IsAllRows=true, TableName = "Table1"
};
var sql = generator.Generate(expression);
sql.ShouldBe("DELETE FROM \"public\".\"Table1\";");
}
示例5: Generate
public override string Generate(DeleteDataExpression expression)
{
var deleteItems = new List<string>();
if (expression.IsAllRows)
{
deleteItems.Add(string.Format(DeleteData, Quoter.QuoteTableName(expression.TableName), "1 = 1"));
}
else
{
foreach (var row in expression.Rows)
{
var whereClauses = new List<string>();
foreach (KeyValuePair<string, object> item in row)
{
whereClauses.Add(string.Format("{0} {1} {2}", Quoter.QuoteColumnName(item.Key), item.Value == null ? "IS" : "=", Quoter.QuoteValue(item.Value)));
}
deleteItems.Add(string.Format(DeleteData, Quoter.QuoteTableName(expression.TableName), String.Join(" AND ", whereClauses.ToArray())));
}
}
return String.Join("; ", deleteItems.ToArray());
}
示例6: Generate
public override string Generate(DeleteDataExpression expression)
{
var result = new StringBuilder();
foreach (var row in expression.Rows)
{
var where = String.Empty;
var i = 0;
foreach (var item in row)
{
if (i != 0)
{
where += " AND ";
}
where += String.Format("[{0}] {1} {2}", item.Key, item.Value == null ? "IS" : "=", Constant.Format(item.Value));
i++;
}
result.Append(String.Format("DELETE FROM {0} WHERE {1};", expression.TableName, where));
}
return result.ToString();
}
示例7: Process
public void Process(DeleteDataExpression expression)
{
Process(Generator.Generate(expression));
}
示例8: GetDeleteDataAllRowsExpression
public static DeleteDataExpression GetDeleteDataAllRowsExpression()
{
var expression = new DeleteDataExpression();
expression.TableName = TestTableName1;
expression.IsAllRows = true;
return expression;
}
示例9: Generate
public override string Generate(DeleteDataExpression expression)
{
var result = new StringBuilder();
if (expression.IsAllRows)
{
result.Append(String.Format("DELETE FROM {0}[{1}];", FormatSchema(expression.SchemaName), expression.TableName));
}
else
{
foreach (var row in expression.Rows)
{
var where = String.Empty;
var i = 0;
foreach (var item in row)
{
if (i != 0)
{
where += " AND ";
}
where += String.Format("[{0}] = {1}", item.Key, Constant.Format(item.Value));
i++;
}
result.Append(String.Format("DELETE FROM {0}[{1}] WHERE {2};", FormatSchema(expression.SchemaName), expression.TableName, where));
}
}
return result.ToString();
}
示例10: CanDeleteTestFromTable
public void CanDeleteTestFromTable()
{
CanInsertAndReadDataFromTestTable();
var delete = new DeleteDataExpression {TableName = "Foo"};
delete.Rows.Add(new DeletionDataDefinition {
new KeyValuePair<string, object>("Id", 1)
});
_processor.Process(delete);
var table = _processor.ReadTableData(string.Empty, "Foo");
0.ShouldBe(table.Tables[0].Rows.Count);
}
示例11: DeleteVersion
public void DeleteVersion(long version)
{
var expression = new DeleteDataExpression { TableName = VersionTableMetaData.TableName, SchemaName = VersionTableMetaData.SchemaName };
expression.Rows.Add(new ExplicitDataDefinition(new DataValue(VersionTableMetaData.ColumnName, version)));
expression.ExecuteWith(Processor);
}
示例12: Generate
public override string Generate(DeleteDataExpression expression)
{
return string.Format("{0};", base.Generate(expression));
}
示例13: Generate
public override string Generate(DeleteDataExpression expression)
{
var deleteItems = new List<string>();
if (expression.IsAllRows)
{
deleteItems.Add(string.Format(DeleteData, Quoter.QuoteTableName(expression.TableName), "1 = 1", CommandDelimiter));
}
else
{
foreach (var row in expression.Rows)
{
IEnumerable<IDataValue> columnData = evaluator.Evaluate(row);
var whereClauses = new List<string>();
foreach (IDataValue item in columnData)
{
whereClauses.Add(string.Format("{0} {1} {2}", Quoter.QuoteColumnName(item.ColumnName), item.Value == null ? "IS" : "=", Quoter.QuoteDataValue(item)));
}
deleteItems.Add(string.Format(DeleteData, Quoter.QuoteTableName(expression.TableName), String.Join(" AND ", whereClauses.ToArray()), CommandDelimiter));
}
}
return String.Join(MultilineDelimiter, deleteItems.ToArray());
}
示例14: Truncate
public void Truncate(DeleteDataExpression expression)
{
expression.TableName = Truncate(expression.TableName);
}
示例15: Generate
public override string Generate(DeleteDataExpression expression)
{
throw new NotImplementedException();
}