当前位置: 首页>>代码示例>>C#>>正文


C# Expressions.UpdateDataExpression类代码示例

本文整理汇总了C#中FluentMigrator.Expressions.UpdateDataExpression的典型用法代码示例。如果您正苦于以下问题:C# UpdateDataExpression类的具体用法?C# UpdateDataExpression怎么用?C# UpdateDataExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UpdateDataExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了UpdateDataExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的FluentMigrator.Expressions.UpdateDataExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。