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


C# Table.AddColumn方法代码示例

本文整理汇总了C#中Table.AddColumn方法的典型用法代码示例。如果您正苦于以下问题:C# Table.AddColumn方法的具体用法?C# Table.AddColumn怎么用?C# Table.AddColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Table的用法示例。


在下文中一共展示了Table.AddColumn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupBase

        protected void SetupBase(string resourcePath)
        {
            loader = new EntityLoader(MockRepository.GenerateStub<IFileController>());

            database = new Database("DB1");
            table1 = new Table("Table1");
            table1.AddColumn(new Column("ID") { Datatype = "int" });
            table1.AddColumn(new Column("BasicClass2_Index") { Datatype = "int" });
            database.AddEntity(table1);

            table2 = new Table("Table2");
            table2.AddColumn(new Column("ID") { Datatype = "int" });
            table2.AddColumn(new Column("BASIC_CLASS_1_ID"));
            database.AddEntity(table2);

            tableManyToMany = new Table("Class1Class2");
            tableManyToMany.AddColumn(new Column("Class1ID") { Datatype = "int" });
            tableManyToMany.AddColumn(new Column("Class2ID") { Datatype = "int" });
            database.AddTable(tableManyToMany);

            relationship = table1.CreateRelationshipTo(table2);
            relationship.PrimaryKey.AddColumn("ID");
            relationship.ForeignKey.AddColumn("BASIC_CLASS_1_ID");

            // Call we are testing
            mappingSet = loader.GetEntities(new[] { Path.Combine("Resources", resourcePath) }, database);
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:27,代码来源:Specs_For_Loading_From_HBM_Files__References.cs

示例2: Csv1_Transformed_Semicolon

 public void Csv1_Transformed_Semicolon()
 {
     var table = new Table<Csv1Row>();
     table.AddColumn(0, "Firstname", x => x.Target.FirstName = x.Value);
     table.AddColumn(1, "Lastname", x => x.Target.LastName = x.Value);
     table.AddColumn(2, "City", x => x.Target.City = x.Value);
     table.AddColumn(3, "Age", x =>
     {
         int age;
         var ok = int.TryParse(x.Value, out age);
         x.Target.Age = age;
         return ok;
     });
     var target = new CsvReader<Csv1Row>(table);
     target.CellSeparator = ';';
     target.HasHeaderLine = true;
     var reader = new StringReader(CsvFiles.Csv1.Replace(CsvFiles.Csv1Separator, ";"));
     var result = target.ReadToEnd(reader);
     Assert.IsNotNull(result);
     Assert.IsNotNull(result.Columns);
     Assert.IsNotNull(result.Rows);
     Assert.AreEqual(4, result.Rows.Count);
     Assert.AreEqual("Firstname", result.Rows[0].Cells[0].Value);
     ////Assert.AreEqual("Firstname", result.Rows[0].Target.FirstName);
     Assert.IsTrue(result.Rows[0].IsHeader);
     Assert.AreEqual("Gregory", result.Rows[1].Cells[0].Value);
     Assert.AreEqual("Gregory", result.Rows[1].Target.FirstName);
     Assert.AreEqual("Gorgini", result.Rows[2].Cells[1].Value);
     Assert.AreEqual("Gorgini", result.Rows[2].Target.LastName);
     Assert.AreEqual("Valenciennes", result.Rows[3].Cells[2].Value);
     Assert.AreEqual("Valenciennes", result.Rows[3].Target.City);
     Assert.AreEqual("100", result.Rows[3].Cells[3].Value);
     Assert.AreEqual(100, result.Rows[3].Target.Age);
 }
开发者ID:sandrock,项目名称:SrkCsv,代码行数:34,代码来源:CsvReaderTests.cs

示例3: WhenCreateTableWithAutoIncrementAsNoPrimaryKey_GetCorrespondingTableScript

        public void WhenCreateTableWithAutoIncrementAsNoPrimaryKey_GetCorrespondingTableScript()
        {
            var table = new Table("TestTables");
            table.AddColumn("MyIdColumn", new Int()).AutoIncrement(primaryKey: false);
            table.AddColumn("MyValue", new NVarChar(100));

            var createScript = table.GetUpScript().Single();

            Assert.Equal("CREATE TABLE TestTables\r\n(\r\nMyIdColumn int IDENTITY(1,1),\r\nMyValue nvarchar(100)\r\n)", createScript);
        }
开发者ID:Rinsen,项目名称:DatabaseInstaller,代码行数:10,代码来源:TableTests.cs

示例4: WhenCreateTableWithNamedPrimaryKey_GetCorrespondingTableScript

        public void WhenCreateTableWithNamedPrimaryKey_GetCorrespondingTableScript()
        {
            var table = new Table("TestTables");
            table.AddColumn("Key1", new Int()).PrimaryKey("PrimaryKeyForTestTables");
            table.AddColumn("Key2", new Int()).PrimaryKey("PrimaryKeyForTestTables");

            var createScript = table.GetUpScript().Single();

            Assert.Equal("CREATE TABLE TestTables\r\n(\r\nKey1 int NOT NULL,\r\nKey2 int NOT NULL,\r\nCONSTRAINT PrimaryKeyForTestTables PRIMARY KEY (Key1,Key2)\r\n)", createScript);
        }
开发者ID:Rinsen,项目名称:DatabaseInstaller,代码行数:10,代码来源:TableTests.cs

示例5: WhenCreateTableWithNotNullAndPrimaryKey_GetCorrespondingTableScript

        public void WhenCreateTableWithNotNullAndPrimaryKey_GetCorrespondingTableScript()
        {
            var table = new Table("TestTables");
            table.AddColumn("MyIdColumn", new Int()).PrimaryKey();
            table.AddColumn("MyValue", new NVarChar(100));

            var createScript = table.GetUpScript().Single();

            Assert.Equal("CREATE TABLE TestTables\r\n(\r\nMyIdColumn int NOT NULL PRIMARY KEY,\r\nMyValue nvarchar(100)\r\n)", createScript);
        }
开发者ID:Rinsen,项目名称:DatabaseInstaller,代码行数:10,代码来源:TableTests.cs

示例6: WhenCreateTableWithNamedUniquesAndOneUniqueColumn_GetCorrespondingTableScript

        public void WhenCreateTableWithNamedUniquesAndOneUniqueColumn_GetCorrespondingTableScript()
        {
            var table = new Table("TestTables");
            table.AddColumn("Col1", new Int()).Unique("PrimaryKeyForTestTables");
            table.AddColumn("Col2", new Int()).Unique("PrimaryKeyForTestTables");
            table.AddColumn("Col3", new Int()).Unique();

            var createScript = table.GetUpScript().Single();

            Assert.Equal("CREATE TABLE TestTables\r\n(\r\nCol1 int,\r\nCol2 int,\r\nCol3 int UNIQUE,\r\nCONSTRAINT PrimaryKeyForTestTables UNIQUE (Col1,Col2)\r\n)", createScript);
        }
开发者ID:Rinsen,项目名称:DatabaseInstaller,代码行数:11,代码来源:TableTests.cs

示例7: AddDbChanges

        public override void AddDbChanges(List<IDbChange> tableCollection)
        {
            var table = new Table(_tableName);
            table.AddColumn("Id", new Int()).PrimaryKey().AutoIncrement();
            table.AddColumn("InstallationName", new NVarChar(1024)).Unique().NotNull();
            table.AddColumn("PreviousVersion", new Int()).NotNull();
            table.AddColumn("StartedInstallingVersion", new Int()).NotNull();
            table.AddColumn("InstalledVersion", new Int()).NotNull();

            tableCollection.Add(table);
        }
开发者ID:Rinsen,项目名称:DatabaseInstaller,代码行数:11,代码来源:InstallerBaseVersion.cs

示例8: TestDatabase

        public static Database TestDatabase()
        {
            Database db = new Database("Test Database");

            var t1 = new Table("Table1");
            db.AddTable(t1);
            t1.AddColumn(new Column("Column1") { InPrimaryKey = true, Datatype = "int", OrdinalPosition = 0, Size = 4});
            t1.AddColumn(new Column("Column2") { Datatype = "nvarchar", OrdinalPosition = 1, Size = 100 });
            t1.AddColumn(new Column("Column3") { Datatype = "datetime", OrdinalPosition = 2, Size = 8 });

            t1.AddIndex(new Index("PK_Table1") { IsUnique = true, Datatype = DatabaseIndexType.PrimaryKey}).AddColumn("Column1");
            t1.AddKey(new Key("PK_Table1", DatabaseKeyType.Primary)).AddColumn("Column1").AddColumn("Column2");

            return db;
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:15,代码来源:TestDatabaseLoader.cs

示例9: The_Rule_Fails_But_Only_For_The_Parent

        public void The_Rule_Fails_But_Only_For_The_Parent()
        {
            var set = new MappingSetImpl();
            var parentEntity = new EntityImpl("Parent");
            var childEntity = new EntityImpl("Child");
            childEntity.Parent = parentEntity;
            var property = new PropertyImpl("Property1");
            parentEntity.AddProperty(property);
            set.EntitySet.AddEntity(parentEntity);
            set.EntitySet.AddEntity(childEntity);

            var table = new Table("Table1");
            var column = new Column("Column1");
            table.AddColumn(column);
            set.Database.AddTable(table);

            var rule = new CheckAllPropertiesMappedRule();
            var result = rule.Run(set);

            Assert.That(result.HasIssues);
            Assert.That(result.Issues, Has.Count(1));

            var issue = result.Issues[0];
            Assert.That(issue.ErrorLevel, Is.EqualTo(ValidationErrorLevel.Warning));
            Assert.That(issue.Object, Is.SameAs(property));
            StringAssert.Contains("Property1", issue.Description);
            StringAssert.Contains("Parent", issue.Description);
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:28,代码来源:Specs_For_All_Properties_Mapped.cs

示例10: Form_Is_Set_Up

        public void Form_Is_Set_Up()
        {
            IComponentSpecificationForm form = MockRepository.GenerateMock<IComponentSpecificationForm>();
            IMainPanel panel = MockRepository.GenerateMock<IMainPanel>();

            var mappingSet = new MappingSetImpl();
            var entity = new EntityImpl("Entity1");
            entity.AddProperty(new PropertyImpl("Property1"));
            var table = new Table("Table1");
            table.AddColumn(new Column("Column1"));
            table.AddColumn(new Column("Street"));
            mappingSet.EntitySet.AddEntity(entity);

            mappingSet.ChangeMappedColumnFor(entity.Properties.First()).To(table.Columns[0]);

            ComponentSpecification spec = new ComponentSpecificationImpl("Address");
            spec.AddProperty(new ComponentPropertyImpl("Street"));
            Component component = spec.CreateImplementedComponentFor(entity, "Street");
            mappingSet.EntitySet.AddComponentSpecification(spec);

            var mapping = new ComponentMappingImpl {ToComponent = component, FromTable = table};
            mapping.AddPropertyAndColumn(component.Properties[0], table.Columns[0]);
            mappingSet.AddMapping(mapping);

            form.Expect(f => f.SetProperties(null))
                .IgnoreArguments()
                .WhenCalled(action => Assert.That(((IEnumerable<ComponentProperty>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            form.Expect(f => f.SetUsages(null))
                .IgnoreArguments()
                .WhenCalled(action => Assert.That(((IEnumerable<Entity>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            form.Expect(f => f.SetFullEntityList(null))
                .IgnoreArguments()
                .WhenCalled(action => Assert.That(((IEnumerable<Entity>)action.Arguments[0]).Count(), Is.EqualTo(1)));

            ComponentSpecificationPresenter presenter = new ComponentSpecificationPresenter(panel, form);
            presenter.AttachToModel(spec);

            form.AssertWasCalled(f => f.Clear());
            form.AssertWasCalled(f => f.SpecName = spec.Name);
            form.AssertWasCalled(f => f.SetVirtualProperties(spec.Ex));

            form.VerifyAllExpectations();
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:45,代码来源:Specs_For_ComponentSpecPresenter.cs

示例11: WhenColumnWithNotNull_GetCorrespondingTableScript

        public void WhenColumnWithNotNull_GetCorrespondingTableScript()
        {
            var table = new Table("TestTables");
            table.AddColumn("MyColumn", new Int()).NotNull();

            var createScript = table.GetUpScript().Single();

            Assert.Equal("CREATE TABLE TestTables\r\n(\r\nMyColumn int NOT NULL\r\n)", createScript);
        }
开发者ID:Rinsen,项目名称:DatabaseInstaller,代码行数:9,代码来源:TableTests.cs

示例12: The_Rule_Fails

        public void The_Rule_Fails()
        {
            var set = new MappingSetImpl();
            var entity = new Table("Table1");
            set.Database.AddTable(entity);
            entity.AddColumn(new Column("Column1"));
            var duplicate = new Column("Column1");
            entity.AddColumn(duplicate);

            DatabaseNamingRule rule = new DatabaseNamingRule();
            var result = rule.Run(set);

            Assert.That(result.Issues, Has.Count(1));

            var issue = result.Issues[0];
            Assert.That(issue.ErrorLevel, Is.EqualTo(ValidationErrorLevel.Error));
            Assert.That(issue.Object, Is.SameAs(duplicate));
            StringAssert.Contains("Column1", issue.Description);
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:19,代码来源:Specs_For_Database_Naming.cs

示例13: CreateTable

        private static ITable CreateTable(IDatabase db, string tableName)
        {
            var table = new Table(tableName);
            table.AddColumn(new Column("Column1"));
            table.AddColumn(new Column("Column2"));
            table.AddColumn(new Column("Column3"));

            var primaryKey = new Key("PrimaryKey", DatabaseKeyType.Primary);
            table.AddKey(primaryKey);
            var foreignKey = new Key("ForeignKey", DatabaseKeyType.Foreign);
            table.AddKey(foreignKey);

            primaryKey.AddColumn("Column1");
            foreignKey.AddColumn("Column1");

            db.AddTable(table);

            return table;
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:19,代码来源:ModelSetup.cs

示例14: Should_Return_This

        public void Should_Return_This()
        {
            const string expectedXML = @"<Table>" + When_Serialising_An_Empty_Table.ScriptBaseXml +
                                       @"<Columns>" + When_Serialising_An_Empty_Column.BasicColumnXml + @"</Columns>" +
                                       @"</Table>";
            Table table = new Table("Entity1");
            table.AddColumn(new Column("Entity1"));

            string outputXML = table.Serialise(new DatabaseSerialisationScheme());
            outputXML = XmlSqueezer.RemoveWhitespaceBetweenElements(outputXML);
            Assert.That(outputXML, Is.EqualTo(expectedXML));
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:12,代码来源:Specs_For_Serialisation_Of_A_Table.cs

示例15: It_Should_Serialise_To_This

        public void It_Should_Serialise_To_This()
        {
            Table table = new Table("Table1");
            Column column = new Column("Column1");
            table.AddColumn(column);

            var dis = new DiscriminatorBuilder()
                .SingleConditionDiscriminator(column, Operator.Equal, new ExpressionValueImpl("5"));

            string outputXML = new EntitySetSerialisationScheme().SerialiseDiscriminator(dis);
            outputXML = XmlSqueezer.RemoveWhitespaceBetweenElements(outputXML);
            Assert.That(outputXML, Is.EqualTo(FullDiscriminatorXml));
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:13,代码来源:Specs_For_Serialisation_Of_Discriminators.cs


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