linq C#中的多个groupby by属性列表

时间:2015-01-25 10:20:52

标签: c# linq

我有 列出GroupProperyKeys 在我的代码中,我获得了属性信息

 List<PropertyInfo> propertiesKeys = new List<PropertyInfo>();
 foreach (string key in this.GroupProperyKeys)
 {
    PropertyInfo p = typeof(T).GetProperty(key);
    if (p != null)
      propertiesKeys.Add(p);
 }

现在我想按给定的属性对列表进行分组。 如果我有一个属性要分组它看起来像这样

PropertyInfo keyProperty = typeof(T).GetProperty(this.GroupProperyKey);
if (keyProperty != null)
{
   var group = m_list.GroupBy(x => keyProperty.GetValue(x));
}

是否可以按属性列表进行分组?

先谢谢你

0 个答案:

没有答案