/// <summary> /// Customers the model CRUD. /// </summary> /// <param name="dbcontext3">The dbcontext3.</param> /// <param name="i">The i.</param> /// <remarks>http://wintersun.cnblogs.com/</remarks> private static void CustomerModelCRUD(TestPerformaceDBDB dbcontext3, int i) { var c1 = new Customer(); c1.CompanyName = "company"; c1.CustomerID = "T" + i; //insert dbcontext3.Insert.Into <Customer>(c => c.CustomerID, c => c.CompanyName).Values(c1.CustomerID, c1.CompanyName).Execute(); //update dbcontext3.Update <Customer>().Set("CompanyName").EqualTo("test").Where <Customer>(x => x.CustomerID == c1.CustomerID).Execute(); //delete dbcontext3.Delete <Customer>(x => x.CustomerID == c1.CustomerID).Execute(); }
/// <summary> /// Writes the test. /// </summary> /// <param name="repeatTime">The repeat time.</param> /// <returns>The write test.</returns> /// <remarks>http://wintersun.cnblogs.com/</remarks> public long WriteTest(int repeatTime) { var dbcontext3 = new TestPerformaceDBDB(); return(Utility.PerformanceWatch( () => { for (int i = 0; i < repeatTime; i++) { CustomerModelCRUD(dbcontext3, i); var category = new Category() { CategoryName = "AirLine", Description = "For Air" }; category.CategoryID = dbcontext3.Insert.Into <Category>(c => c.CategoryName, c => c.Description).Values(category.CategoryName, category.Description).Execute(); dbcontext3.Update <Category>().Set("CategoryName").EqualTo("testupdate").Where <Category>(x => x.CategoryID == category.CategoryID).Execute(); var product = new Product() { ProductName = "testproduct1", UnitPrice = 10, QuantityPerUnit = "tt", SupplierID = 3, CategoryID = category.CategoryID }; product.ProductID = dbcontext3.Insert.Into <Product>(p => p.ProductName, p => p.UnitPrice, p => p.QuantityPerUnit, p => p.SupplierID) .Values(product.ProductName, product.UnitPrice, product.QuantityPerUnit, product.SupplierID).Execute(); dbcontext3.Update <Product>().Set("ProductName").EqualTo("updateproductname").Where <Product>(p => p.ProductID == product.ProductID).Execute(); dbcontext3.Delete <Category>(x => x.CategoryID == category.CategoryID).Execute(); dbcontext3.Delete <Product>(x => x.ProductID == product.ProductID).Execute(); } })); }