那么伙计......我有这个问题:
Allow the user view the top five selling products in descending order grouped by country.
这是我的代码:
var q6 = (from t in northwind.Products
join o in northwind.Suppliers on t.SupplierID equals o.SupplierID
group t.UnitPrice by new {o.Country, t.UnitPrice} into grouped
let county = grouped.Key.Country
let price = grouped.Key.UnitPrice
group new
{
Country = county,
Product = price
}
by county
into countryGrouped
select new
{
Output = countryGrouped.Key,
Price = countryGrouped.OrderBy(c => c.Product)
});
lbxTop5.ItemsSource = q6;
就输出价格而言。
价格如下:
有谁能告诉我如何以正确的格式而不是数据类型输出价格?
谢谢!
答案 0 :(得分:0)
什么是“正确格式”?
您可以这样做:
...
select new
{
Output = countryGrouped.Key,
Price = string.Join(",", countryGrouped.OrderBy(c => c.Product))
});
这将使输出成为逗号分隔的字符串