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


C# TestDb.CreateTable方法代码示例

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


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

示例1: SetUp

        public void SetUp()
        {
            _db = new TestDb();
            _db.CreateTable<Product>();
            _db.CreateTable<Order>();
            _db.CreateTable<OrderLine>();

            var p1 = new Product { Name = "One", };
            var p2 = new Product { Name = "Two", };
            var p3 = new Product { Name = "Three", };
            _db.InsertAll(new[] { p1, p2, p3 });

            var o1 = new Order { PlacedTime = DateTime.Now, };
            var o2 = new Order { PlacedTime = DateTime.Now, };
            _db.InsertAll(new[] { o1, o2 });

            _db.InsertAll(new[] {
                new OrderLine {
                    OrderId = o1.Id,
                    ProductId = p1.Id,
                    Quantity = 1,
                },
                new OrderLine {
                    OrderId = o1.Id,
                    ProductId = p2.Id,
                    Quantity = 2,
                },
                new OrderLine {
                    OrderId = o2.Id,
                    ProductId = p3.Id,
                    Quantity = 3,
                },
            });
        }
开发者ID:Banane9,项目名称:sqlite-net,代码行数:34,代码来源:JoinTest.cs

示例2: CreateDb

 TestDb CreateDb()
 {
     var db = new TestDb ();
     db.CreateTable<Product> ();
     db.CreateTable<Order> ();
     db.CreateTable<OrderLine> ();
     db.CreateTable<OrderHistory> ();
     return db;
 }
开发者ID:roufamatic,项目名称:sqlite-net,代码行数:9,代码来源:LinqTest.cs

示例3: UpperAndLowerColumnNames

        public void UpperAndLowerColumnNames()
        {
            using (var db = new TestDb (true) { Trace = true } ) {
                db.CreateTable<LowerId> ();
                db.CreateTable<UpperId> ();

                var cols = db.GetTableInfo ("Test").ToList ();
                Assert.AreEqual (1, cols.Count);
                Assert.AreEqual ("Id", cols[0].Name);
            }
        }
开发者ID:x4maT,项目名称:sqlite-net,代码行数:11,代码来源:MigrationTest.cs

示例4: CreateThem

		public void CreateThem ()
		{
			var db = new TestDb ();
			
			db.CreateTable<Product> ();
			db.CreateTable<Order> ();
			db.CreateTable<OrderLine> ();
			db.CreateTable<OrderHistory> ();
			
			VerifyCreations(db);
		}
开发者ID:golddragon007,项目名称:sqlite-net,代码行数:11,代码来源:CreateTableTest.cs

示例5: UpperAndLowerColumnNames

        public void UpperAndLowerColumnNames()
        {
            using (var db = new TestDb (true) { Trace = true } ) {
                db.CreateTable<LowerId> ();
                db.CreateTable<UpperId> ();

                var cols = db.GetTableInfo ("Test").ToList ();
                Assert.That (cols.Count, Is.EqualTo (1));
                Assert.That (cols[0].Name, Is.EqualTo ("Id"));
            }
        }
开发者ID:dbuksbaum,项目名称:sqlite-net,代码行数:11,代码来源:MigrationTest.cs

示例6: CreateAsPassedInTypes

        public void CreateAsPassedInTypes ()
        {
            var db = new TestDb();

            db.CreateTable(typeof(Product));
            db.CreateTable(typeof(Order));
            db.CreateTable(typeof(OrderLine));
            db.CreateTable(typeof(OrderHistory));

            VerifyCreations(db);
        }
开发者ID:golddragon007,项目名称:sqlite-net,代码行数:11,代码来源:CreateTableTest.cs

示例7: CreateDbWithOne2Many

		SQLiteConnection CreateDbWithOne2Many ()
		{
			var db = new TestDb ()
				.SetForeignKeysPermissions(true);
			db.CreateTable<TestObjWithOne2Many> ();
			db.CreateTable<TestDependentObj> ();
			var items = Enumerable.Range(1,parentCount)
							.Select(i => new TestObjWithOne2Many {Id = i, 
																  ObjList = Enumerable.Range(1,childCount)
																	.Select(x => new TestDependentObj{OwnerId = i})
																										.ToList()}).ToList();
			db.InsertAll (items);
			Assert.AreEqual (parentCount, db.Table<TestObjWithOne2Many> ().Count ());
			Assert.AreEqual (parentCount * childCount , db.Table<TestDependentObj> ().Count ());
			return db;
		}
开发者ID:snvector,项目名称:sqlite-net,代码行数:16,代码来源:DeleteTest.cs

示例8: SetUp

		public void SetUp ()
		{
			db = new TestDb ();
			db.Trace = true;
			db.CreateTable<Product> ();
			db.CreateTable<Order> ();
			db.InsertAll (from i in Enumerable.Range (0, 22)
				select new Product { Name = "Thing" + i, Price = (decimal)Math.Pow (2, i) });

			changeCount = 0;

			db.TableChanged += (sender, e) => {

				if (e.Table.TableName == "Product") {
					changeCount++;
				}
			};
		}
开发者ID:89sos98,项目名称:sqlite-net,代码行数:18,代码来源:TableChangedTest.cs

示例9: CreateThem

        public void CreateThem()
        {
            var db = new TestDb ();

            db.CreateTable<Product> ();
            db.CreateTable<Order> ();
            db.CreateTable<OrderLine> ();
            db.CreateTable<OrderHistory> ();

            var orderLine = db.GetMapping(typeof(OrderLine));
            Assert.AreEqual(6, orderLine.Columns.Length, "Order history has 3 columns");

            var l = new OrderLine() {
                Status = OrderLineStatus.Shipped
            };
            db.Insert(l);
            var lo = db.Table<OrderLine>().Where(x => x.Status == CreateTableTest.OrderLineStatus.Shipped).FirstOrDefault();
            Assert.AreEqual(lo.Id, l.Id);
        }
开发者ID:Ngugi1,项目名称:sqlite-net,代码行数:19,代码来源:CreateTableTest.cs

示例10: CreateDb

		SQLiteConnection CreateDb ()
		{
			var db = new TestDb ();
			db.CreateTable<TestTable> ();
			var items = from i in Enumerable.Range (0, Count)
				select new TestTable { Datum = 1000+i };
			db.InsertAll (items);
			Assert.AreEqual (Count, db.Table<TestTable> ().Count ());
			return db;
		}
开发者ID:89sos98,项目名称:sqlite-net,代码行数:10,代码来源:DeleteTest.cs

示例11: CreateUniqueIndexes

 public void CreateUniqueIndexes()
 {
     using (var db = new TestDb ()) {
         db.CreateTable<TheOne> ();
         var indexes = db.Query<IndexInfo> ("PRAGMA INDEX_LIST (\"TheOne\")");
         Assert.AreEqual (4, indexes.Count, "# of indexes");
         CheckIndex (db, indexes, "UX_Uno", true, "Uno");
         CheckIndex (db, indexes, "UX_Dos", true, "Dos", "Tres");
         CheckIndex (db, indexes, "UX_Uno_bool", true, "Cuatro");
         CheckIndex (db, indexes, "UX_Dos_bool", true, "Cinco", "Seis");
     }
 }
开发者ID:Toshik,项目名称:sqlite-net,代码行数:12,代码来源:UniqueTest.cs

示例12: SetUp

		public void SetUp ()
		{
			db = new TestDb ();
			db.CreateTable<Product> ();
			
			var prods = new[] {
				new Product { Name = "Foo" },
				new Product { Name = "Bar" },
				new Product { Name = "Foobar" },
			};
			
			db.InsertAll (prods);
		}
开发者ID:golddragon007,项目名称:sqlite-net,代码行数:13,代码来源:StringQueryTest.cs

示例13: HasGoodNames

        public void HasGoodNames()
        {
            var db = new TestDb ();

            db.CreateTable<AFunnyTableName> ();

            var mapping = db.GetMapping<AFunnyTableName> ();

            Assert.AreEqual ("AGoodTableName", mapping.TableName);

            Assert.AreEqual ("Id", mapping.Columns [0].Name);
            Assert.AreEqual ("AGoodColumnName", mapping.Columns [1].Name);
        }
开发者ID:ariesy,项目名称:sqlite-net,代码行数:13,代码来源:MappingTest.cs

示例14: InsertSucceeds

		public void InsertSucceeds ()
		{
			var db = new TestDb ();
			db.CreateTable<TestObj> ();

			var o = new TestObj {
				Text = "Hello",
				IgnoredText = "World",
			};

			db.Insert (o);

			Assert.AreEqual (1, o.Id);
		}
开发者ID:BenjaminKim,项目名称:sqlite-net,代码行数:14,代码来源:IgnoreTest.cs

示例15: ImplicitPK

        public void ImplicitPK()
        {
            var db = new TestDb();

            db.CreateTable<NoAttributes>(CreateFlags.ImplicitPK);

            var mapping = db.GetMapping<NoAttributes>();

            Assert.IsNotNull(mapping.PK);
            Assert.AreEqual("Id", mapping.PK.Name);
            Assert.IsTrue(mapping.PK.IsPK);
            Assert.IsFalse(mapping.PK.IsAutoInc);

            CheckPK(db);
        }
开发者ID:TycTak,项目名称:sqlite-net,代码行数:15,代码来源:CreateTableImplicitTest.cs


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