public virtual void TestCompareTwoConstantEntityNestedRelationshipNegation() { Order exclude = new Order() { OrderID = 10702 }; Customer alfki = new Customer() { CustomerID = "ALFKI" }; var testQuery = from o in db.Orders where o.Customer == alfki && o != exclude select o; var test = testQuery.ToList(); AssertValue(5, test.Count); AssertValue("ALFKI", test[0].CustomerID); }
public void TestInsertOrderWithNoResult() { this.TestInsertCustomerNoResult(); var order = new Order { CustomerID = "XX1", OrderDate = DateTime.Today, }; var result = db.Orders.Insert(order); Assert.AreNotEqual(0, order.OrderID); Assert.AreEqual(1, result); }
public virtual void TestCompareConstantEntityNestedRelationshipNegation() { var exclude = new Order() { OrderID = 10702 }; var testQuery = from c in db.Customers from o in c.Orders from d in o.Details where o != exclude select d; var test = testQuery.ToList(); AssertValue(2153, test.Count); }
//主键是自动增一的实体插入(Oracle数据表通过序列和触发器的方式,约定的Oracle序列必须是全局的,序列名称是:NEXTID public void InsertWithPrimaryKey_IsDbGenerated() { //1. 创建PO对象 Customer c = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; var order = new Order { CustomerID = c.CustomerID, OrderDate = DateTime.Now, }; //2. 创建DbContext 对象 using (var db = cfg.CreateDbContext()) { //3. 创建DbSet对象 var cusotmers = db.Set<Customer>(); var orders = db.Set<Order>(); //4. 删除所有以“XX”开头的CustomerID记录 orders.Delete(p => p.CustomerID.StartsWith("XX")); cusotmers.Delete(p => p.CustomerID.StartsWith("XX")); //在订单插入前,OrderId= 0 Assert.IsTrue(order.OrderID == 0); //5. 执行PO插入 cusotmers.Insert(c); orders.Insert(order); //在订单插入前,OrderId> 0 Assert.IsTrue(order.OrderID > 0); orders.Delete(order); cusotmers.Delete(c); } }