public void TestCustomersIncludeOrdersAndDetails() { var policy = new EntityPolicy(); policy.IncludeWith <Customer>(c => c.Orders); policy.IncludeWith <Order>(o => o.Details); Northwind nw = new Northwind(this.provider.New(policy)); TestQuery( nw.Customers ); }
public void TestCustomersWhereIncludeOrdersAndDetails() { var policy = new EntityPolicy(); policy.IncludeWith <Customer>(c => c.Orders); policy.IncludeWith <Order>(o => o.Details); Northwind nw = new Northwind(this.provider.New(policy)); TestQuery( from c in nw.Customers where c.City == "London" select c ); }
public void TestCustomersIncludeOrders() { var policy = new EntityPolicy(); policy.IncludeWith <Customer>(c => c.Orders); Northwind nw = new Northwind(this.GetProvider().WithPolicy(policy)); TestQuery( nw.Customers ); }
public void TestCustomersIncludeOrdersDeferred() { var policy = new EntityPolicy(); policy.IncludeWith <Customer>(c => c.Orders, true); Northwind nw = new Northwind(this.provider.New(policy)); TestQuery( nw.Customers ); }
public void TestCustomersIncludeOrdersViaConstructorOnly() { var mapping = new AttributeMapping(typeof(NorthwindX)); var policy = new EntityPolicy(); policy.IncludeWith <CustomerX>(c => c.Orders); NorthwindX nw = new NorthwindX(this.provider.New(policy).New(mapping)); TestQuery( nw.Customers ); }
public void TestCustomersWhereIncludeOrders() { var policy = new EntityPolicy(); policy.IncludeWith <Customer>(c => c.Orders); Northwind nw = new Northwind(this.GetProvider().WithPolicy(policy)); TestQuery( from c in nw.Customers where c.City == "London" select c ); }
public void TestCustomersIncludeThenAssociateOrders() { var policy = new EntityPolicy(); policy.IncludeWith<Customer>(c => c.Orders); policy.AssociateWith<Customer>(c => c.Orders.Where(o => (o.OrderID & 1) == 0)); Northwind nw = new Northwind(this.provider.New(policy)); var custs = nw.Customers.Where(c => c.CustomerID == "ALFKI").ToList(); AssertValue(1, custs.Count); AssertNotValue(null, custs[0].Orders); AssertValue(3, custs[0].Orders.Count); }
public void TestCustomersIncludeOrdersDeferred() { var policy = new EntityPolicy(); policy.IncludeWith<Customer>(c => c.Orders, true); Northwind nw = new Northwind(this.provider.New(policy)); var custs = nw.Customers.Where(c => c.CustomerID == "ALFKI").ToList(); AssertValue(1, custs.Count); AssertNotValue(null, custs[0].Orders); AssertValue(6, custs[0].Orders.Count); }
public void TestCustomersIncludeOrdersViaConstructorOnly() { var mapping = new AttributeMapping(typeof(NorthwindX)); var policy = new EntityPolicy(); policy.IncludeWith<CustomerX>(c => c.Orders); NorthwindX nw = new NorthwindX(this.provider.New(policy).New(mapping)); var custs = nw.Customers.Where(c => c.CustomerID == "ALFKI").ToList(); AssertValue(1, custs.Count); AssertNotValue(null, custs[0].Orders); AssertValue(6, custs[0].Orders.Count); }
public void TestCustomersIncludeOrdersAndDetails() { var policy = new EntityPolicy(); policy.IncludeWith<Customer>(c => c.Orders); policy.IncludeWith<Order>(o => o.Details); Northwind nw = new Northwind(this.provider.New(policy)); var custs = nw.Customers.Where(c => c.CustomerID == "ALFKI").ToList(); AssertValue(1, custs.Count); AssertNotValue(null, custs[0].Orders); AssertValue(6, custs[0].Orders.Count); AssertTrue(custs[0].Orders.Any(o => o.OrderID == 10643)); AssertNotValue(null, custs[0].Orders.Single(o => o.OrderID == 10643).Details); AssertValue(3, custs[0].Orders.Single(o => o.OrderID == 10643).Details.Count); }
public void TestOrdersIncludeDetailsWithGroupBy() { var policy = new EntityPolicy(); policy.IncludeWith<Order>(o => o.Details); Northwind nw = new Northwind(this.provider.New(policy)); var list = nw.Orders.Where(o => o.CustomerID == "ALFKI").GroupBy(o => o.CustomerID).ToList(); AssertValue(1, list.Count); var grp = list[0].ToList(); AssertValue(6, grp.Count); var o10643 = grp.SingleOrDefault(o => o.OrderID == 10643); AssertNotValue(null, o10643); AssertValue(3, o10643.Details.Count); }
public void TestOrdersIncludeDetailsWithFirst() { EntityPolicy policy = new EntityPolicy(); policy.IncludeWith<Order>(o => o.Details); var ndb = new Northwind(provider.New(policy)); var q = from o in ndb.Orders where o.OrderID == 10248 select o; Order so = q.Single(); AssertValue(3, so.Details.Count); Order fo = q.First(); AssertValue(3, fo.Details.Count); }
public void TestInsertCustomersIncludeOrders() { var policy = new EntityPolicy(); policy.IncludeWith<Customer>(c => c.Orders); policy.IncludeWith<Order>(o => o.Details); Northwind nw = new Northwind(this.provider.New(policy)); var cust = new Customer { CustomerID = "XX1", CompanyName = "Company1", ContactName = "Contact1", City = "Seattle", Country = "USA" }; var order = new Order { CustomerID = "XX1", OrderDate = DateTime.Today, }; cust.Orders = new List<Order> { order }; var custs = nw.Customers.Insert(cust); var result = nw.Orders.Insert(order); cust = nw.Customers.GetById(cust.CustomerID); Assert.AreEqual(1, custs); //TODO: Complete Assert //Assert.IsNotNull(custs[0].Orders); //Assert.AreEqual(6, custs[0].Orders.Count); //Assert.IsTrue(custs[0].Orders.Any(o => o.OrderID == 10643)); //Assert.IsNotNull(custs[0].Orders.Single(o => o.OrderID == 10643).Details); //Assert.AreEqual(3, custs[0].Orders.Single(o => o.OrderID == 10643).Details.Count); }
public void TestCustomersIncludeOrdersWhere() { var policy = new EntityPolicy(); policy.IncludeWith<Customer>(c => c.Orders.Where(o => (o.OrderID & 1) == 0)); Northwind nw = new Northwind(this.provider.New(policy)); var custs = nw.Customers.Where(c => c.CustomerID == "ALFKI").ToList(); Assert.AreEqual(1, custs.Count); Assert.IsNotNull(custs[0].Orders); Assert.AreEqual(3, custs[0].Orders.Count); }