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


C# TestDb.GetMapping方法代码示例

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


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

示例1: MappingIgnoreColumn

        public void MappingIgnoreColumn()
        {
            var db = new TestDb();
            var m = db.GetMapping<TestObj>();

            Assert.AreEqual(2, m.Columns.Length);
        }
开发者ID:Banane9,项目名称:sqlite-net,代码行数:7,代码来源:IgnoreTest.cs

示例2: InheritanceWorks

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

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

            Assert.AreEqual (3, mapping.Columns.Length);
            Assert.AreEqual ("Id", mapping.PK.Name);
        }
开发者ID:chaosnhatred,项目名称:sqlite-net,代码行数:9,代码来源:InheritanceTest.cs

示例3: VerifyCreations

        private static void VerifyCreations(TestDb db)
        {
            var orderLine = db.GetMapping(typeof(OrderLine));
            Assert.AreEqual(6, orderLine.Columns.Length);

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

示例4: 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

示例5: InheritanceWorks

        public void InheritanceWorks()
        {
            var fluentMapping = new TableBuilder<Derived>()
                .AsPrimaryKey(p => p.Id)
                .Build();

            SQLiteConnection.RegsiterMappings(new List<TableMapping>{ fluentMapping });
            var db = new TestDb();
            db.EnsureRegisteredMappings();
            var mapping = db.GetMapping<Derived>();

            Assert.AreEqual(3, mapping.Columns.Length);
            Assert.AreEqual("Id", mapping.PK.Name);
        }
开发者ID:rgmills,项目名称:sqlite-net,代码行数:14,代码来源:InheritanceTest.cs

示例6: 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

示例7: WithoutImplicitMapping

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

            db.CreateTable<NoAttributes>();

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

            Assert.IsNull (mapping.PK);

            var column = mapping.Columns[2];
            Assert.AreEqual("IndexedId", column.Name);
            Assert.IsFalse(column.Indices.Any());

            Assert.Throws(typeof(AssertionException), () => CheckPK(db));
        }
开发者ID:TycTak,项目名称:sqlite-net,代码行数:16,代码来源:CreateTableImplicitTest.cs

示例8: 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

示例9: ImplicitIndex

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

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

            var mapping = db.GetMapping<NoAttributes>();
            var column = mapping.Columns[2];
            Assert.AreEqual("IndexedId", column.Name);
            Assert.IsTrue(column.Indices.Any());
        }
开发者ID:TycTak,项目名称:sqlite-net,代码行数:11,代码来源:CreateTableImplicitTest.cs

示例10: ImplicitAutoInc

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

            db.CreateTable<PkAttribute>(CreateFlags.AutoIncPK);

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

            Assert.IsNotNull(mapping.PK);
            Assert.AreEqual("Id", mapping.PK.Name);
            Assert.IsTrue(mapping.PK.IsPK);
            Assert.IsTrue(mapping.PK.IsAutoInc);
        }
开发者ID:TycTak,项目名称:sqlite-net,代码行数:13,代码来源:CreateTableImplicitTest.cs

示例11: ImplicitPKAutoIncAsPassedInTypes

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

            db.CreateTable(typeof(NoAttributes), CreateFlags.ImplicitPK | CreateFlags.AutoIncPK);

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

            Assert.IsNotNull(mapping.PK);
            Assert.AreEqual("Id", mapping.PK.Name);
            Assert.IsTrue(mapping.PK.IsPK);
            Assert.IsTrue(mapping.PK.IsAutoInc);
        }
开发者ID:TycTak,项目名称:sqlite-net,代码行数:13,代码来源:CreateTableImplicitTest.cs

示例12: ExecuteNonQueryWithNullThrowsException

		public void ExecuteNonQueryWithNullThrowsException ()
		{
			using (TestDb db = new TestDb ()) {
				TableMapping map;

				db.CreateTable<NotNullNoPK> ();

				try {
					NotNullNoPK obj = new NotNullNoPK () {
						AnotherRequiredStringProp = "Another required prop",
						RequiredIntProp = 123,
						RequiredStringProp = "Required string prop"
					};
					db.Insert (obj);

					map = db.GetMapping<NotNullNoPK> ();
					map.GetInsertCommand (db, "OR REPLACE").ExecuteNonQuery (new object[] { 1, null, 123, null, null, null });
				}
				catch (NotNullConstraintViolationException) {
					return;
				}
				catch (SQLiteException ex) {
					if (SQLite3.LibVersionNumber () < 3007017 && ex.Result == SQLite3.Result.Constraint) {
						Inconclusive ();
						return;
					}
				}
				catch (Exception ex) {
					Assert.Fail ("Expected an exception of type NotNullConstraintViolationException to be thrown. An exception of type {0} was thrown instead.", ex.GetType ().Name);
				}
			}
			Assert.Fail ("Expected an exception of type NotNullConstraintViolationException to be thrown. No exception was thrown.");
		}
开发者ID:89sos98,项目名称:sqlite-net,代码行数:33,代码来源:NotNullAttributeTest.cs


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