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


C# TableSchema.Insert方法代码示例

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


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

示例1: SchemaIndicesShouldAlwaysIncrease

        public void SchemaIndicesShouldAlwaysIncrease()
        {
            //initialize table with 5 cols
            var table = new TableSchema("T",
                                        new FieldSchema("C1"),
                                        new FieldSchema("C2"),
                                        new FieldSchema("C3"),
                                        new FieldSchema("C4"),
                                        new FieldSchema("C5")
                );
            Assert.IsNotNull(table);
            Assert.AreEqual(5, table.Count);
            Assert.AreEqual(5, table.Counter);
            CollectionAssert.AreEquivalent(new[] { "C1", "C2", "C3", "C4", "C5" }, table.Keys);
            Assert.AreEqual(1, table["C1"].Index);
            Assert.AreEqual(2, table["C2"].Index);
            Assert.AreEqual(3, table["C3"].Index);
            Assert.AreEqual(4, table["C4"].Index);
            Assert.AreEqual(5, table["C5"].Index);

            //add 2 cols
            table.Insert(new FieldSchema("C6"), new FieldSchema("C7"));
            Assert.AreEqual(7, table.Count);
            Assert.AreEqual(7, table.Counter);
            CollectionAssert.AreEquivalent(new[] { "C1", "C2", "C3", "C4", "C5", "C6", "C7" }, table.Keys);
            Assert.AreEqual(1, table["C1"].Index);
            Assert.AreEqual(2, table["C2"].Index);
            Assert.AreEqual(3, table["C3"].Index);
            Assert.AreEqual(4, table["C4"].Index);
            Assert.AreEqual(5, table["C5"].Index);
            Assert.AreEqual(6, table["C6"].Index);
            Assert.AreEqual(7, table["C7"].Index);

            //remove 3 cols
            table.Delete(table["C4"], table["C5"], table["C6"]);
            Assert.AreEqual(4, table.Count);
            Assert.AreEqual(7, table.Counter);
            CollectionAssert.AreEquivalent(new[] { "C1", "C2", "C3", "C7" }, table.Keys);
            Assert.AreEqual(1, table["C1"].Index);
            Assert.AreEqual(2, table["C2"].Index);
            Assert.AreEqual(3, table["C3"].Index);
            Assert.IsNull(table["C4"]);
            Assert.IsNull(table["C5"]);
            Assert.IsNull(table["C6"]);
            Assert.AreEqual(7, table["C7"].Index);

            //add 3 cols
            table.Insert(new FieldSchema("C4"),new FieldSchema("C5"),new FieldSchema("C6"));
            Assert.AreEqual(7, table.Count);
            Assert.AreEqual(10, table.Counter);
            CollectionAssert.AreEquivalent(new[] {"C1", "C2", "C3", "C7", "C4", "C5", "C6"}, table.Keys);
            Assert.AreEqual(1, table["C1"].Index);
            Assert.AreEqual(2, table["C2"].Index);
            Assert.AreEqual(3, table["C3"].Index);
            Assert.AreEqual(7, table["C7"].Index);
            Assert.AreEqual(8, table["C4"].Index);
            Assert.AreEqual(9, table["C5"].Index);
            Assert.AreEqual(10, table["C6"].Index);
        }
开发者ID:wpq0,项目名称:FormNG,代码行数:59,代码来源:SchemaTest.cs


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