如何从Dynamic Linq获取Max值

时间:2015-02-04 09:02:01

标签: c# .net linq

如何从Dynamic Linq获取最大值?

public Func<TSource, T> DynamicMax<TSource, T>(string fieldName, object className)
            {
                var type = typeof(TSource);
                var pe = Expression.Parameter(type, "p");
                var propertyReference = Expression.Property(pe, fieldName);
                var constantReference = Expression.Constant(className);

                return Expression.Lambda<Func<TSource, T>>
                    (Expression.IsTrue(propertyReference, constantReference), pe).Compile();
            }

0 个答案:

没有答案