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); }
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); }
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); } }