为了账号安全,请及时绑定邮箱和手机立即绑定

C# - LINQ - 在另一个 LINQ 查询的 WHERE 子句中使用列数据

C# - LINQ - 在另一个 LINQ 查询的 WHERE 子句中使用列数据

C#
米脂 2021-06-03 10:37:55
所以我执行这个查询:            var query2 = from o in db.Orders                     join od in db.Order_Details on o.OrderID equals od.OrderID                     group new { o, od } by o.ShipCountry into oByCountry                     orderby oByCountry.Sum(ood => ood.od.UnitPrice * ood.od.Quantity) descending                     select new                     {                         Country = oByCountry.Key,                         Total = oByCountry.Sum(ood => ood.od.UnitPrice * ood.od.Quantity)                     };我将结果放在 WPF 中的数据网格中。GridOverview.ItemsSource = query2;我要做的下一件事是,当我在一行中按下 GridOverview 时,我想显示居住在所选行所在国家/地区的所有客户以及每个客户的已售商品总价。所以我在 var selectedRow 中定义了所选项目。var selectedRow = GridOverview.SelectedItem;            var query = from c in db.Customers                    join o in db.Orders on c.CustomerID equals o.CustomerID                    join od in db.Order_Details on o.OrderID equals od.OrderID                    **where c.Country == selectedRow.**                    group new {c, o, od} by c.CompanyName into cByName                    orderby cByName.Sum(ood => ood.od.UnitPrice * ood.od.Quantity) descending                    select new                    {                        cByName.Key,                        Total = cByName.Sum(ood => ood.od.UnitPrice * ood.od.Quantity)                    };现在我的问题是:如何在 where 子句中将 selectedRow 的 Country 与 C.Country 进行比较?selectedRow.Country 不起作用,但这可能不是它的工作原理。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 190 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信