public static IQueryable <T> dtSelect <T>(this IQueryable <T> source, NameValueCollection request, params Expression <Func <T, object> >[] selects) { string key = RequestKey <T>(request); RequestDTSelects.Add(key, selects); return(source); }
public static IQueryable <T> dtSelect <T>(this IQueryable <T> source, NameValueCollection request, params string[] selects) { string key = RequestKey <T>(request); var paramExpression = Expression.Parameter(typeof(T), "val"); PropertyInfo[] _properties = selects.Select(s => typeof(T).GetProperty(s)).ToArray(); Expression <Func <T, object> >[] searches = _properties.Select(p => Expression.Lambda <Func <T, object> >(Expression.Convert(Expression.Property(paramExpression, p), typeof(object)), paramExpression)).ToArray(); RequestDTSelects.Add(key, searches); return(source); }