public void TestCustomersApplyOrderAndAssociateOrders() { var policy = new EntityPolicy(); policy.Apply<Order>(ords => ords.Where(o => o.OrderDate != null)); 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(); AssertValue(1, custs.Count); AssertNotValue(null, custs[0].Orders); AssertValue(3, custs[0].Orders.Count); }
public void TestCustomersApplyFilterTwice() { var policy = new EntityPolicy(); policy.Apply<Customer>(seq => seq.Where(c => c.City == "London")); policy.Apply<Customer>(seq => seq.Where(c => c.Country == "UK")); Northwind nw = new Northwind(this.provider.New(policy)); var custs = nw.Customers.ToList(); AssertValue(6, custs.Count); }
public void TestCustomersApplyOrder() { var policy = new EntityPolicy(); policy.Apply<Customer>(seq => seq.OrderBy(c => c.ContactName)); Northwind nw = new Northwind(this.provider.New(policy)); var list = nw.Customers.Where(c => c.City == "London").ToList(); AssertValue(6, list.Count); var sorted = list.OrderBy(c => c.ContactName).ToList(); AssertTrue(Enumerable.SequenceEqual(list, sorted)); }
public void TestCustomersApplyComputedFilter() { string ci = "Lon"; string ty = "don"; var policy = new EntityPolicy(); policy.Apply<Customer>(seq => seq.Where(c => c.City == ci + ty)); Northwind nw = new Northwind(this.provider.New(policy)); var custs = nw.Customers.ToList(); AssertValue(6, custs.Count); }