LINQにはかなり新しく、私がやろうとしていることは簡単にするべきだと思います。私は製品リスト(ProductId
、ProductDesc
)を持っており、そのリストのサブセットを取り出し、それをProductId
でグループ化しようとしています。そこから、そのサブセットをlistViewにバインドしたいと思います。LINQ Select and Group By
productCounts = (from record in wowReportData
group record by record.ProductID
into grouping
orderby grouping.Key
select new topProduct
{
ProductID = grouping.Key,
Quantity = grouping.Count(),
Name = grouping.
}).ToList();
、ここでは、私が移入しようとしているクラスです:
public class topProduct
{
public string ProductID { get; set; }
public int Quantity { get; set; }
public string Name { get; set; }
public topProduct() { }
public topProduct(string productId, string productDesc, int downloadCount)
{
this.ProductID = productId;
this.Name = productDesc;
this.Quantity = downloadCount;
}
}
私はそれだけでproductId
を表示すると正常に動作し、カウントが、私は必要としていたここで私が働いているクエリですディスプレイに説明を追加することもできます。私はグループ化をしているときに製品の説明を追加する方法については混乱しています。
を '命名について見てください'ProductID'でグループ化された' wowReportData'のリストです。名前が 'wowReportData'の一部であれば' grouping.First()。Name'を実行できますが、 'Name'に配置したいものがわからない場合 –