• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Expressions.InsertDataExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CanMigrateTableWithIdentityData

        public void CanMigrateTableWithIdentityData()
        {
            // Arrange
              var create = new CreateTableExpression
              {
              TableName = "Foo"
             ,
              Columns = new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32, IsIdentity = true} }
              };
              var context = GetDefaultContext();

              var insert = new InsertDataExpression()
              {
              TableName = "Foo"
              };
              insert.Rows.Add(new InsertionDataDefinition { new KeyValuePair<string, object>("Id", 1)});
              insert.Rows.Add(new InsertionDataDefinition { new KeyValuePair<string, object>("Id", 100) });
              insert.WithIdentity = true;

              // Act
              MigrateTable(context, create, insert);

              // Assert
              context.MigrationIndex.ShouldBe(1);
        }
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:25,代码来源:SqlServerMigrationTests.cs


示例2: UpdateVersionInfo

 public void UpdateVersionInfo(long version, string description)
 {
     var dataExpression = new InsertDataExpression();
     dataExpression.Rows.Add(CreateVersionInfoInsertionData(version, description));
     dataExpression.TableName = VersionTableMetaData.TableName;
     dataExpression.SchemaName = VersionTableMetaData.SchemaName;
     
     dataExpression.ExecuteWith(Processor);
 }
开发者ID:SaltyDH,项目名称:fluentmigrator,代码行数:9,代码来源:VersionLoader.cs


示例3: Reverse

        public IMigrationExpression Reverse()
        {
            var expression = new InsertDataExpression
            {
                SchemaName = SchemaName,
                TableName = TableName
            };

            expression.Rows.AddRange(Rows);

            return expression;
        }
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:12,代码来源:DeleteDataExpression.cs


示例4: ExplicitUnicodeStringIgnoredForNonSqlServer

        public void ExplicitUnicodeStringIgnoredForNonSqlServer()
        {
            var expression = new InsertDataExpression {TableName = "TestTable"};
            expression.Rows.Add(new InsertionDataDefinition
                                    {
                                        new KeyValuePair<string, object>("NormalString", "Just'in"),
                                        new KeyValuePair<string, object>("UnicodeString", new ExplicitUnicodeString("codethinked'.com"))
                                    });

            var result = Generator.Generate(expression);
            result.ShouldBe("INSERT INTO \"public\".\"TestTable\" (\"NormalString\",\"UnicodeString\") VALUES ('Just''in','codethinked''.com');");
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:12,代码来源:PostgresGeneratorTests.cs


示例5: CanInsertAtAtIdentity

        public void CanInsertAtAtIdentity()
        {
            var expression = new InsertDataExpression {TableName = "TestTable"};
            expression.Rows.Add(new InsertionDataDefinition
                                    {
                                        new KeyValuePair<string, object>("Id", 1),
                                        new KeyValuePair<string, object>("Name", RawSql.Insert("@@IDENTITY")),
                                        new KeyValuePair<string, object>("Website", "codethinked.com")
                                    });

            var result = Generator.Generate(expression);
            result.ShouldBe("INSERT INTO [dbo].[TestTable] ([Id], [Name], [Website]) VALUES (1, @@IDENTITY, 'codethinked.com')");
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:13,代码来源:SqlServer2008GeneratorTests.cs


示例6: ExplicitUnicodeQuotesCorrectly

        public void ExplicitUnicodeQuotesCorrectly()
        {
            var expression = new InsertDataExpression {TableName = "TestTable"};
            expression.Rows.Add(new InsertionDataDefinition
                                    {
                                        new KeyValuePair<string, object>("UnicodeStringValue", new ExplicitUnicodeString("UnicodeString")),
                                        new KeyValuePair<string, object>("StringValue", "AnsiiString")
                                    });

            var result = Generator.Generate(expression);
            result.ShouldBe("INSERT INTO [dbo].[TestTable] ([UnicodeStringValue], [StringValue]) VALUES (N'UnicodeString', 'AnsiiString')");

        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:13,代码来源:SqlServer2008GeneratorTests.cs


示例7: Generate

        public override string Generate(InsertDataExpression expression)
        {
            var insertStrings = new List<string>();

            foreach (IDataDefinition row in expression.Rows)
            {
                IEnumerable<IDataValue> dataValues = evaluator.Evaluate(row).ToArray();

                string columns = String.Join(", ", dataValues.Select(dataValue => Quoter.QuoteColumnName(dataValue.ColumnName)).ToArray());
                string values = String.Join(", ", dataValues.Select(dataValue => Quoter.QuoteDataValue(dataValue)).ToArray());

                insertStrings.Add(String.Format(InsertData, Quoter.QuoteTableName(expression.TableName), columns, values, CommandDelimiter));
            }

            return "INSERT ALL " + String.Join(" ", insertStrings.ToArray()) + " SELECT 1 FROM DUAL";
        }
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:16,代码来源:OracleGenerator.cs


示例8: Reverse

        public IMigrationExpression Reverse()
        {
            var expression = new InsertDataExpression
            {
                SchemaName = SchemaName,
                TableName = TableName
            };

            foreach (var row in Rows)
            {
                var dataDefinition = new InsertionDataDefinition();
                dataDefinition.AddRange(row);

                expression.Rows.Add(dataDefinition);
            }

            return expression;
        }
开发者ID:BhuvanB,项目名称:fluentmigrator,代码行数:18,代码来源:DeleteDataExpression.cs


示例9: Generate

        public override string Generate(InsertDataExpression expression)
        {
            var columnNames = new List<string>();
            var columnValues = new List<string>();
            var insertStrings = new List<string>();

            foreach (InsertionDataDefinition row in expression.Rows)
            {
                columnNames.Clear();
                columnValues.Clear();
                foreach (KeyValuePair<string, object> item in row)
                {
                    columnNames.Add(Quoter.QuoteColumnName(item.Key));
                    columnValues.Add(Quoter.QuoteValue(item.Value));
                }

                string columns = String.Join(", ", columnNames.ToArray());
                string values = String.Join(", ", columnValues.ToArray());
                insertStrings.Add(String.Format(InsertData, Quoter.QuoteTableName(expression.TableName), columns, values));
            }
            return "INSERT ALL " + String.Join(" ", insertStrings.ToArray()) + " SELECT 1 FROM DUAL";
        }
开发者ID:swalters,项目名称:fluentmigrator,代码行数:22,代码来源:OracleGenerator.cs


示例10: CanInsertBinaryData

        public void CanInsertBinaryData()
        {
            var expression = new InsertDataExpression
            {
                TableName = "TestTable1"
            };

            var row1 = new { Id = 1, Name = "Just'in", Value = Encoding.ASCII.GetBytes("Just'in") };
            var row2 = new { Id = 1, Name = "Na\te", Value = Encoding.ASCII.GetBytes("Na\te") };

            expression.Rows.AddRange(new IDataDefinition[]
                {
                    new ReflectedDataDefinition(row1),
                    new ReflectedDataDefinition(row2)
                }
            );

            var sql = generator.Generate(expression);

            var expected = "INSERT INTO `TestTable1` (`Id`, `Name`, `Value`) VALUES (1, 'Just''in', UNHEX('4A75737427696E'));";
            expected += "\r\nINSERT INTO `TestTable1` (`Id`, `Name`, `Value`) VALUES (1, 'Na	e', UNHEX('4E610965'));";

            sql.ShouldBe(expected);
        }
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:24,代码来源:MySqlDataTests.cs


示例11: CanInsertGuidData

        public void CanInsertGuidData()
        {
            var gid = Guid.NewGuid();
            var expression = new InsertDataExpression { TableName = "TestTable" };
            expression.Rows.Add(new ExplicitDataDefinition(new DataValue("guid", gid)));

            var sql = generator.Generate(expression);

            var expected = String.Format("INSERT INTO \"public\".\"TestTable\" (\"guid\") VALUES ('{0}');", gid);

            sql.ShouldBe(expected);
        }
开发者ID:ibebbs,项目名称:fluentmigrator,代码行数:12,代码来源:PostgresGeneratorTests.cs


示例12: UpdateVersionInfo

 public void UpdateVersionInfo(long version, Type type, TimeSpan elapsedTime)
 {
     var dataExpression = new InsertDataExpression();
     dataExpression.Rows.Add( CreateVersionInfoInsertionData( version, type, elapsedTime ) );
     dataExpression.TableName = VersionTableMetaData.TableName;
     dataExpression.SchemaName = VersionTableMetaData.SchemaName;
     dataExpression.ExecuteWith( Processor );
 }
开发者ID:mgaspar,项目名称:fluentmigrator,代码行数:8,代码来源:VersionLoader.cs


示例13: Generate

        public override string Generate(InsertDataExpression expression)
        {
            var result = new StringBuilder();
            foreach (var row in expression.Rows)
            {
                var columnNames = new List<string>();
                var columnData = new List<object>();
                foreach (var item in row)
                {
                    columnNames.Add(item.Key);
                    columnData.Add(item.Value);
                }

                var columns = GetColumnList(columnNames);
                var data = GetDataList(columnData);
                result.Append(String.Format("INSERT INTO {0}.{1} ({2}) VALUES ({3});", Quoter.QuoteSchemaName(expression.SchemaName), Quoter.QuoteTableName(expression.TableName), columns, data));
            }
            return result.ToString();
        }
开发者ID:VSoftTechnologies,项目名称:fluentmigrator,代码行数:19,代码来源:PostgresGenerator.cs


示例14: Generate

 public override string Generate(InsertDataExpression expression)
 {
     if (IsUsingIdentityInsert(expression))
     {
         return string.Format("{0}; {1}; {2}",
                     string.Format(IdentityInsert, Quoter.QuoteTableName(expression.TableName), "ON"),
                     base.Generate(expression),
                     string.Format(IdentityInsert, Quoter.QuoteTableName(expression.TableName), "OFF"));
     }
     return base.Generate(expression);
 }
开发者ID:kramerpr,项目名称:fluentmigrator,代码行数:11,代码来源:SqlServer2000Generator.cs


示例15: IsUsingIdentityInsert

        protected static bool IsUsingIdentityInsert(InsertDataExpression expression)
        {
            if (expression.AdditionalFeatures.ContainsKey(SqlServerExtensions.IdentityInsert))
            {
                return (bool)expression.AdditionalFeatures[SqlServerExtensions.IdentityInsert];
            }

            return false;
        }
开发者ID:kramerpr,项目名称:fluentmigrator,代码行数:9,代码来源:SqlServer2000Generator.cs


示例16: GetInsertDataExpression

        public static InsertDataExpression GetInsertDataExpression()
        {
            var expression = new InsertDataExpression();
            expression.TableName = TestTableName1;
            expression.Rows.Add(new InsertionDataDefinition
                                    {
                                        new KeyValuePair<string, object>("Id", 1),
                                        new KeyValuePair<string, object>("Name", "Just'in"),
                                        new KeyValuePair<string, object>("Website", "codethinked.com")
                                    });
            expression.Rows.Add(new InsertionDataDefinition
                                    {
                                        new KeyValuePair<string, object>("Id", 2),
                                        new KeyValuePair<string, object>("Name", @"Na\te"),
                                        new KeyValuePair<string, object>("Website", "kohari.org")
                                    });

            return expression;
        }
开发者ID:hazzik,项目名称:fluentmigrator,代码行数:19,代码来源:GeneratorTestHelper.cs


示例17: GetInsertGUIDExpression

        public static InsertDataExpression GetInsertGUIDExpression()
        {
            var expression = new InsertDataExpression { TableName = TestTableName1 };
            expression.Rows.Add(new InsertionDataDefinition { new KeyValuePair<string, object>("guid", TestGuid) });

            return expression;
        }
开发者ID:hazzik,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs


示例18: Generate

        public override string Generate(InsertDataExpression expression)
        {
            var result = new StringBuilder();
            foreach (InsertionDataDefinition row in expression.Rows)
            {
                List<string> columnNames = new List<string>();
                List<object> columnData = new List<object>();
                foreach (KeyValuePair<string, object> item in row)
                {
                    columnNames.Add(item.Key);
                    columnData.Add(item.Value);
                }

                string columns = GetColumnList(columnNames);
                string data = GetDataList(columnData);
                result.Append(String.Format(" INTO {0} ({1}) VALUES ({2})", expression.TableName, columns, data));
            }
            return "INSERT ALL" + result.ToString() + " SELECT 1 FROM DUAL";
        }
开发者ID:carlhoerberg,项目名称:fluentmigrator,代码行数:19,代码来源:OracleGenerator.cs


示例19: IdentityCanInsertMultiple

        public void IdentityCanInsertMultiple()
        {
            using (var table = new FirebirdTestTable(Processor, null, "bogus int"))
            {
                Processor.Process(new CreateColumnExpression
                {
                    TableName = table.Name,
                    Column = { Name = "id", IsIdentity = true, Type = DbType.Int64, IsPrimaryKey = true }
                });

                var insert = new InsertDataExpression { TableName = table.Name };
                var item = new Model.InsertionDataDefinition();
                item.Add(new System.Collections.Generic.KeyValuePair<string, object>("BOGUS", 0));
                insert.Rows.Add(item);

                //Process 5 times = insert 5 times
                Processor.Process(insert);
                Processor.Process(insert);
                Processor.Process(insert);
                Processor.Process(insert);
                Processor.Process(insert);

                using (DataSet ds = ((DataSetContainer)Processor.ReadTableData(String.Empty, table.Name)).DataSet)
                {
                    ds.Tables.Count.ShouldBe(1);
                    ds.Tables[0].Rows.Count.ShouldBe(5);
                    ds.Tables[0].Rows[0]["BOGUS"].ShouldBe(0);
                    ds.Tables[0].Rows[0]["id"].ShouldBe(1);
                    ds.Tables[0].Rows[1]["id"].ShouldBe(2);
                    ds.Tables[0].Rows[2]["id"].ShouldBe(3);
                    ds.Tables[0].Rows[3]["id"].ShouldBe(4);
                    ds.Tables[0].Rows[4]["id"].ShouldBe(5);
                }

            }
        }
开发者ID:dmirmilshteyn,项目名称:fluentmigrator,代码行数:36,代码来源:FirebirdProcessorTests.cs


示例20: Generate

        public override string Generate(InsertDataExpression expression)
        {
            if (compatabilityMode == CompatabilityMode.STRICT)
            {
                List<string> unsupportedFeatures = expression.AdditionalFeatures.Keys.Where(x => !IsAdditionalFeatureSupported(x)).ToList();

                if (unsupportedFeatures.Any())
                {
                    string errorMessage =
                        string.Format("The following database specific additional features are not supported in strict mode [{0}]",
                                      expression.AdditionalFeatures.Keys.Aggregate((x, y) => x + ", " + y));
                    return compatabilityMode.HandleCompatabilty(errorMessage);
                }
            }

            List<string> columnNames = new List<string>();
            List<string> columnValues = new List<string>();
            List<string> insertStrings = new List<string>();

            foreach (InsertionDataDefinition row in expression.Rows)
            {
                columnNames.Clear();
                columnValues.Clear();
                foreach (KeyValuePair<string, object> item in row)
                {
                    columnNames.Add(Quoter.QuoteColumnName(item.Key));
                    columnValues.Add(Quoter.QuoteValue(item.Value));
                }

                string columns = String.Join(", ", columnNames.ToArray());
                string values = String.Join(", ", columnValues.ToArray());
                insertStrings.Add(String.Format(InsertData, Quoter.QuoteTableName(expression.TableName), columns, values));
            }
            return String.Join("; ", insertStrings.ToArray());
        }
开发者ID:fire-eagle,项目名称:fluentmigrator,代码行数:35,代码来源:GenericGenerator.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Expressions.RenameColumnExpression类代码示例发布时间:2022-05-26
下一篇:
C# Expressions.DeleteTableExpression类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap