public IEnumerable <object> SelectFields(IEnumerable <TSource> source, IEnumerable <string> fields) { var sourceType = typeof(TSource); var resultType = WithFieldsTypeBag.Get(sourceType, fields); var func = (Func <TSource, object>)MapperFuncBag.Get(sourceType, resultType); return(source.Select(func)); }
public IQueryable <object> SelectFields(IQueryable <TSource> source, IEnumerable <string> fields) { var sourceType = typeof(TSource); var resultType = WithFieldsTypeBag.Get(sourceType, fields); var expression = MapperExpressionBag.Get(sourceType, resultType); var selectMethod = SelectMethodInfo.MakeGenericMethod(sourceType, resultType); return((IQueryable <object>)selectMethod.Invoke(null, new object[] { source, expression })); }