2
我有类似下面的模式:EF 4 CTP 5复杂的查询
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<Order> Orders { get; set; }
}
public class Order
{
public int Id { get; set; }
public DateTime DateTime { get; set; }
public Customer Customer { get; set; }
public ICollection<OrderLine> OrderLines { get; set; }
}
public class OrderLine
{
public int Id { get; set; }
public Product Product { get; set; }
public int Price { get; set; }
public int Quantity { get; set; }
}
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public Category Category { get; set; }
}
public class Category
{
public int Id { get; set; }
public string Name { get; set; }
}
我的聚合根源是Customer,Order,Product。因为它们很简单,所以我没有在这里包含映射。
var customers = unitOfWork.Customers.FindAll();
var orders = unitOfWork.Orders.FindAll();
var products = unitOfWork.Products.FindAll();
var query = ......
使用LINQ,您将如何选择在“饮料”类别中有产品订单的所有客户?
我在网上看到的所有样本都是非常基本的查询,没有任何先进的。
您的产品没有类别信息。 – 2011-02-17 11:21:42
产品到类别的参考在哪里? – Nagg 2011-02-17 11:22:49