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


C# TestDb.Execute方法代码示例

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


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

示例1: UpdateQueryWithNullThrowsException

		public void UpdateQueryWithNullThrowsException ()
		{
			// Skip this test if the Dll doesn't support the extended SQLITE_CONSTRAINT codes
			using (TestDb db = new TestDb ()) {

				db.CreateTable<NotNullNoPK> ();

				try {
					db.Execute ("insert into \"NotNullNoPK\" (AnotherRequiredStringProp, RequiredIntProp, RequiredStringProp) values(?, ?, ?)",
						new object[] { "Another required string", 123, "Required string" });

					db.Execute ("update \"NotNullNoPK\" set AnotherRequiredStringProp=?, RequiredIntProp=?, RequiredStringProp=? where ObjectId=?",
						new object[] { "Another required string", 123, null, 1 });
				}
				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,代码行数:29,代码来源:NotNullAttributeTest.cs

示例2: TenThousandRecords

        public void TenThousandRecords()
        {
            using (var db = new TestDb()) {

                db.Trace = false;
                //db.Execute("PRAGMA journal_mode = MEMORY", new object[] { });
                //sqlite3_exec(db, "PRAGMA synchronous = OFF", NULL, NULL, &sErrMsg);
                //sqlite3_exec(db, "PRAGMA journal_mode = MEMORY", NULL, NULL, &sErrMsg);
                db.Execute("PRAGMA synchronous = OFF", new object[] { });
                db.Execute("PRAGMA journal_mode = MEMORY", new object[] { });

                db.CreateTable<OrderLine>();

                var st = DateTime.Now;

                int doFor = 1; //was 15

                //for (int i = 0; i < 1000; i++) {
                //    var l = new OrderLine() {
                //        Status = OrderLineStatus.Shipped
                //    };
                //    db.Insert(l);
                //}

                //var end = DateTime.Now.Subtract(st).TotalMilliseconds;

                //st = DateTime.Now;

                for (int times = 0; times < doFor; times++) {
                    db.BeginTransaction();

                    //for (int i = 0; i < 20000; i++) {
                    //    var l = new OrderLine() {
                    //        OrderId = 12,
                    //        ProductId = 14,
                    //        Quantity = 54,
                    //        UnitPrice = 12.95M
                    //    };
                    //    db.Insert(l);
                    //}

                    for (int i = 0; i < 10000; i++) {
                        var l = new OrderLine() {
                            OrderId = 12,
                            ProductId = 14,
                            Quantity = 54,
                            UnitPrice = 12.95M
                        };
                        db.Insert(l);
                    }

                    //for (int i = 0; i < 10000; i++) {
                    //    var l = new OrderLine() {
                    //        OrderId = 12 + i,
                    //        ProductId = 14 + i,
                    //        Quantity = 54 + i,
                    //        UnitPrice = (12.95M + (decimal)i)
                    //    };
                    //    db.Insert(l);
                    //}

                    db.Commit();
                }

                var end2 = DateTime.Now.Subtract(st).TotalMilliseconds;
                Console.WriteLine(end2);
            }
        }
开发者ID:joefeser,项目名称:sqlite-net,代码行数:68,代码来源:InterfaceTests.cs


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