解决方案 »

  1.   

    http://weblogs.asp.net/scottgu/dynamic-linq-part-1-using-the-linq-dynamic-query-library
      

  2.   

    这个需要用那个library的库,我是在silverlight前端用这个功能,好多类是由限制的
      

  3.   

    那你写个反射,用来获取指定字段的值,比如l.MachineLineRange就是Foo("MachineLineRange")
      

  4.   

    http://blog.csdn.net/q107770540/article/details/6133484 var query = fids.GroupBy(l => new {MachineLineRange=GetPropertyValue(l,"MachineLineRange"), MachineLine=GetPropertyValue(l,"MachineLine")})
               .Select(g => new
                {
                    MachineLineRange = g.Key.MachineLineRange,
                    Qty = g.Sum(a => a.Qty),
                    MachineLine = g.Key.MachineLine,
                });
    private static object GetPropertyValue(object obj, string property)  
    {  
        System.Reflection.PropertyInfo propertyInfo=obj.GetType().GetProperty(property);  
        return propertyInfo.GetValue(obj, null);  
    }  
      

  5.   

    谢谢,我有找到这种解决办法,但是下面那个Select里面也需要是动态的
      

  6.   

    以前写的一个,参考一下吧:
    http://blog.csdn.net/davinciyxw/article/details/8930063