public void TestUseAutoMapperEntity() { string tsqlstr = "SELECT Top 1 * FROM [Products] "; Database db = DatabaseFactory.CreateDatabase("TestDB"); var cmd = db.GetSqlStringCommand(tsqlstr); var product = new Product(); using (IDataReader reader = db.ExecuteReader(cmd)) { if (reader.Read()) { //auto map product = AutoMapper.Mapper.DynamicMap<Product>(reader); } } Assert.IsNotNull(product); Console.WriteLine(product.ProductName); }
/// <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 _db = Database.Open(); return Utility.PerformanceWatch( () => { for (int i = 0; i < repeatTime; i++) { var customer = new Customer { CompanyName = "Newcompanyname", ContactName = "ccc", Address = "asdcasdws", ContactTitle = "asdf", City = "kuna", Country = "china", Phone = "231", PostalCode = "234", Region = "asia", CustomerID = "9011" }; _db.Customers.Insert(customer); //update customer.ContactName = "updated contact"; _db.Customers.Update(customer); _db.Customers.DeleteByCustomerID(customer.CustomerID); //insert category var category = new Category { CategoryName = "Shipment", Description = "for test" }; var newCategory = _db.Categories.Insert(category); var product = new Product { ProductName = "productname", CategoryID = newCategory.CategoryID, SupplierID = 1 }; var newProduct = _db.Products.Insert(product); newCategory.CategoryName = "Updated"; _db.Categories.Update(newCategory); newProduct.ProductName = "updated product"; _db.Products.Update(newProduct); //delete _db.Products.DeleteByProductID(newProduct.ProductID); _db.Categories.DeleteByCategoryID(newCategory.CategoryID); } }); }