0
我想LINQ查詢是這樣的:基於主和細節過濾如何?
var q = from order in Order
join detail in Detail on order.OrderId equals detail.OrderId
,允許我做以下可選的過濾,基於用戶的選擇:
if (cbxCustomer.Text != string.Empty)
{
q = q.Where(x=>x.CustomerId = (int)cbxCustomer.SelectedItem) // filter based on master
}
if (cbxItem.Text != string.Empty)
{
q = q.Where(x=>x.ItemId = (int)cbxItem.SelectedItem) // filter based on detail
}
的結果應該是訂單的,沒有重複的列表回答上面的可選過濾器。
感謝