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 TestCustomersAssociateOrders() { var policy = new EntityPolicy(); 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") .Select(c => new { CustomerID = c.CustomerID, FilteredOrdersCount = c.Orders.Count() }).ToList(); AssertValue(1, custs.Count); AssertValue(3, custs[0].FilteredOrdersCount); }