以下の例をご覧ください。Group Clause は動的でなければなりません。これを達成する方法を教えてください。つまり、行
{ r.Portfolio, r.DataType }
動的に構築する必要があります。
ブログhttp://jonahacquah.blogspot.com/2012/02/groupby-multiple-columns-using-dynamic.htmlに示されているように、ソリューションを微調整する方法がわからない
public class DecisionSupportData
{
public string Portfolio { get; set; }
public string BucketName { get; set; }
public string DataType { get; set; }
public string ChildPortfolio { get; set; }
}
public void PopulateData()
{
List<DecisionSupportData> lstAllDecSupp = decisionSupportDataBindingSource.DataSource as List<DecisionSupportData>;
List<DecisionSupportData> lstRmgAmt
= (from r in lstAllDecSupp.AsEnumerable()
where r.DataType == "P"
group r by new { r.Portfolio, r.DataType } into gg
select new DecisionSupportData
{
DataType = gg.Key.DataType,
Portfolio = gg.Key.Portfolio,
}).ToList();
}