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