请看下面的例子。组子句必须是动态的。您能否指导我如何实现这一目标。即行
{ 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();
}