本文整理汇总了C#中FluentMigrator.Expressions.UpdateDataExpression类的典型用法代码示例。如果您正苦于以下问题:C# UpdateDataExpression类的具体用法?C# UpdateDataExpression怎么用?C# UpdateDataExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UpdateDataExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了UpdateDataExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize()
{
expression =
new UpdateDataExpression()
{
TableName = "ExampleTable",
Set = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("Column", "value")
},
IsAllRows = false
};
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:13,代码来源:UpdateDataExpressionTests.cs
示例2: Generate
public abstract string Generate(UpdateDataExpression expression);
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:1,代码来源:GeneratorBase.cs
示例3: Generate
public override string Generate(UpdateDataExpression expression)
{
throw new NotImplementedException();
}
开发者ID:robinvarg,项目名称:fluentmigrator,代码行数:4,代码来源:PostgresGenerator.cs
示例4: Generate
public override string Generate(UpdateDataExpression expression)
{
return string.Format("UPDATE {0}.{1}", Quoter.QuoteSchemaName(expression.SchemaName), base.Generate(expression));
}
开发者ID:hazzik,项目名称:fluentmigrator,代码行数:4,代码来源:SqlServer2005Generator.cs
示例5: Truncate
public void Truncate(UpdateDataExpression expression)
{
expression.TableName = Truncate(expression.TableName);
}
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:4,代码来源:FirebirdTruncator.cs
示例6: Generate
public override string Generate(UpdateDataExpression expression)
{
List<string> updateItems = new List<string>();
List<string> whereClauses = new List<string>();
foreach (var item in expression.Set)
{
updateItems.Add(string.Format("{0} = {1}", Quoter.QuoteColumnName(item.Key), Quoter.QuoteValue(item.Value)));
}
if(expression.IsAllRows)
{
whereClauses.Add("1 = 1");
}
else
{
foreach (var item in expression.Where)
{
whereClauses.Add(string.Format("{0} {1} {2}", Quoter.QuoteColumnName(item.Key),
item.Value == null ? "IS" : "=", Quoter.QuoteValue(item.Value)));
}
}
return String.Format(UpdateData, Quoter.QuoteTableName(expression.TableName), String.Join(", ", updateItems.ToArray()), String.Join(" AND ", whereClauses.ToArray()));
}
开发者ID:robertmircea,项目名称:fluentmigrator,代码行数:24,代码来源:GenericGenerator.cs
示例7: GetUpdateDataExpression
public static UpdateDataExpression GetUpdateDataExpression()
{
var expression = new UpdateDataExpression();
expression.TableName = TestTableName1;
expression.Set = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("Name", "Just'in"),
new KeyValuePair<string, object>("Age", 25)
};
expression.Where = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("Id", 9),
new KeyValuePair<string, object>("Homepage", null)
};
return expression;
}
开发者ID:hazzik,项目名称:fluentmigrator,代码行数:18,代码来源:GeneratorTestHelper.cs
示例8: IfMigrationHasAnInvalidExpressionDuringUpActionShouldThrowAnExceptionAndAnnounceTheError
public void IfMigrationHasAnInvalidExpressionDuringUpActionShouldThrowAnExceptionAndAnnounceTheError()
{
var invalidMigration = new Mock<IMigration>();
var invalidExpression = new UpdateDataExpression {TableName = "Test"};
invalidMigration.Setup(m => m.GetUpExpressions(It.IsAny<IMigrationContext>())).Callback((IMigrationContext mc) => mc.Expressions.Add(invalidExpression));
Assert.Throws<InvalidMigrationException>(() => _runner.Up(invalidMigration.Object));
_announcer.Verify(a => a.Error(It.Is<string>(s => s.Contains("UpdateDataExpression: Update statement is missing a condition. Specify one by calling .Where() or target all rows by calling .AllRows()."))));
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:10,代码来源:MigrationRunnerTests.cs
示例9: GetUpdateDataExpressionWithAllRows
public static UpdateDataExpression GetUpdateDataExpressionWithAllRows()
{
var expression = new UpdateDataExpression();
expression.TableName = TestTableName1;
expression.Set.AddRange(new[] { new ExplicitDataDefinition(new DataValue("Name", "Just'in"), new DataValue("Age", 25)) });
expression.IsAllRows = true;
return expression;
}
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:10,代码来源:GeneratorTestHelper.cs
示例10: GetUpdateDataExpression
public static UpdateDataExpression GetUpdateDataExpression()
{
var expression = new UpdateDataExpression();
expression.TableName = TestTableName1;
expression.Set.AddRange(new [] { new ExplicitDataDefinition(new DataValue("Name", "Just'in"), new DataValue("Age", 25)) } );
expression.Where.AddRange(new [] { new ExplicitDataDefinition(new DataValue("Id", 9), new DataValue("Homepage", null)) } );
return expression;
}
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:10,代码来源:GeneratorTestHelper.cs
示例11: Table
public IUpdateSetOrInSchemaSyntax Table(string tableName)
{
var expression = new UpdateDataExpression { TableName = tableName };
_context.Expressions.Add(expression);
return new UpdateDataExpressionBuilder(expression, _context);
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:6,代码来源:UpdateExpressionRoot.cs
示例12: Generate
public override string Generate(UpdateDataExpression expression)
{
return string.Format("UPDATE {0}", base.Generate(expression));
}
开发者ID:rebootd,项目名称:fluentmigrator,代码行数:4,代码来源:SqlServerCeGenerator.cs
示例13: CanUpdateTable
public void CanUpdateTable()
{
CanInsertAndReadDataFromTestTable();
var expression = new UpdateDataExpression { TableName = "Foo"
, Set = new List<KeyValuePair<string, object>> { new KeyValuePair<string, object>("Id", 2) }
, Where = new List<KeyValuePair<string, object>> { new KeyValuePair<string, object>("Id", 1) }
};
_processor.Process(expression);
var table = _processor.ReadTableData(string.Empty, "Foo");
1.ShouldBe(table.Tables[0].Rows.Count);
2.ShouldBe(table.Tables[0].Rows[0]["Id"]);
}
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:16,代码来源:OracleProcessorTests.cs
示例14: Generate
public override string Generate(UpdateDataExpression expression)
{
string setClause = EvaluateSet(expression.Set);
string whereClause = expression.IsAllRows ? "1 = 1" : EvaluateWhere(expression.Where);
return String.Format(UpdateData, Quoter.QuoteTableName(expression.TableName), setClause, whereClause, CommandDelimiter);
}
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:7,代码来源:GenericGenerator.cs
示例15: Truncate
public void Truncate(UpdateDataExpression expression)
{
expression.TableName = Truncate(expression.TableName);
List<KeyValuePair<string, object>> newSet = new List<KeyValuePair<string, object>>();
foreach (var data in expression.Set)
{
newSet.Add(new KeyValuePair<string, object>(Truncate(data.Key), data.Value));
}
expression.Set.Clear();
expression.Set.AddRange(newSet);
if (!expression.IsAllRows)
{
List<KeyValuePair<string, object>> newWhere = new List<KeyValuePair<string, object>>();
foreach (var data in expression.Where)
{
newWhere.Add(new KeyValuePair<string, object>(Truncate(data.Key), data.Value));
}
expression.Where.Clear();
expression.Where.AddRange(newWhere);
}
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:21,代码来源:FirebirdTruncator.cs
示例16: CanUpdateData
public void CanUpdateData()
{
var expression = new UpdateDataExpression();
expression.TableName = "Table1";
expression.Set = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("Name", "Just'in"),
new KeyValuePair<string, object>("Age", 25)
};
expression.Where = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("Id", 9),
new KeyValuePair<string, object>("Homepage", null)
};
var sql = generator.Generate(expression);
sql.ShouldBe("UPDATE [Table1] SET [Name] = 'Just''in', [Age] = 25 WHERE [Id] = 9 AND [Homepage] IS NULL");
}
开发者ID:gliljas,项目名称:fluentmigrator,代码行数:20,代码来源:JetGeneratorTests.cs
示例17: Generate
public override string Generate(UpdateDataExpression expression)
{
var result = new StringBuilder();
var set = String.Empty;
var i = 0;
foreach (var item in expression.Set)
{
if (i != 0)
{
set += ", ";
}
set += String.Format("[{0}] = {1}", item.Key, Constant.Format(item.Value));
i++;
}
var where = String.Empty;
i = 0;
foreach (var item in expression.Where)
{
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("UPDATE [{0}] SET {1} WHERE {2};", expression.TableName, set, where));
return result.ToString();
}
开发者ID:carlhoerberg,项目名称:fluentmigrator,代码行数:34,代码来源:OracleGenerator.cs
示例18: CanUpdateBinaryData
public void CanUpdateBinaryData()
{
var expression = new UpdateDataExpression
{
TableName = "TestTable1"
};
var set = new { Name = "Just'in", Value = Encoding.ASCII.GetBytes("Just'in") };
var where = new { Id = 1 };
expression.Set.Add(new ReflectedDataDefinition(set));
expression.Where.Add(new ReflectedDataDefinition(where));
var sql = generator.Generate(expression);
string expected = @"UPDATE `TestTable1` SET `Name` = 'Just''in', `Value` = UNHEX('4A75737427696E') WHERE `Id` = 1;";
sql.ShouldBe(expected);
}
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:19,代码来源:MySqlDataTests.cs
示例19: IfMigrationHasTwoInvalidExpressionsShouldAnnounceBothErrors
public void IfMigrationHasTwoInvalidExpressionsShouldAnnounceBothErrors()
{
var invalidMigration = new Mock<IMigration>();
var invalidExpression = new UpdateDataExpression { TableName = "Test" };
var secondInvalidExpression = new CreateColumnExpression();
invalidMigration.Setup(m => m.GetUpExpressions(It.IsAny<IMigrationContext>()))
.Callback((IMigrationContext mc) => { mc.Expressions.Add(invalidExpression); mc.Expressions.Add(secondInvalidExpression); });
Assert.Throws<InvalidMigrationException>(() => _runner.Up(invalidMigration.Object));
_announcer.Verify(a => a.Error(It.Is<string>(s => s.Contains("UpdateDataExpression: Update statement is missing a condition. Specify one by calling .Where() or target all rows by calling .AllRows()."))));
_announcer.Verify(a => a.Error(It.Is<string>(s => s.Contains("CreateColumnExpression: The table's name cannot be null or an empty string. The column's name cannot be null or an empty string. The column does not have a type defined."))));
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:13,代码来源:MigrationRunnerTests.cs
示例20: UpdateDataExpressionBuilder
public UpdateDataExpressionBuilder(UpdateDataExpression expression, IMigrationContext context)
{
_context = context;
_expression = expression;
}
开发者ID:RenaldSB,项目名称:fluentmigrator,代码行数:5,代码来源:UpdateDataExpressionBuilder.cs
注:本文中的FluentMigrator.Expressions.UpdateDataExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论