0
我使用的是通用存儲庫模式,如this article中所示。EF中的主詳細查詢和通用存儲庫模式CF
這些都是我的POCO類:
public class Order
{
public int ID { get; set; }
public int CustomerID {get; set;}
[InverseProperty("Order")]
public virtual List<OrderDetail> OrderDetail {get; set;}
public static Expression<Func<Order, bool>> OrdersFromCustomer(decimal customerId)
{
return f => f.CustomerID == customerId;
}
}
public class OrderDetail
{
public int OrderID { get; set;}
public int ID { get; set;}
public int ItemID { get; set;}
public int Amount { get; set;}
[ForeignKey("OrderID")]
public virtual Order { get; set;}
}
所以當我的節目,我想通過一個客戶得到所有的訂單我可以這樣做:
using (MyDbContext context = new MyDbContext())
{
MyRepository repository = new MyRepository(context);
var orders = repository.Get(Order.OrdersFromCustomer(25));
}
它的偉大工程,但我有一個問題:如果我想要金額大於100的所有訂單?我如何才能爲OrderFromCustomer函數的細節構建過濾器的表達式?
我也試過用LinqKit但沒有結果。