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


C# Expressions.InsertDataExpression类代码示例

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


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


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