开发者

Filter based on master and detail how to?

开发者 https://www.devze.com 2023-03-10 02:15 出处:网络
I want a Linq query like this: var q = from order in Order joi开发者_高级运维n detail in Detail on order.OrderId equals detail.OrderId

I want a Linq query like this:

var q = from order in Order
joi开发者_高级运维n detail in Detail on order.OrderId equals detail.OrderId

That permits me to do the following optional filtering, based on user choice :

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
}

the result should be a list of orders with no duplicates that answers the above optional filter.

Thanks


After applying the filter, you need to select just Orders and than use Distinct LINQ extension method.

0

精彩评论

暂无评论...
验证码 换一张
取 消