示例#1
0
        private Expression Project(Expression input, Expression output)
        {
            var job = new MapJob(_inputArg, _outputArg);

            var fn   = _provider.CreateProjectionFunction(job);
            var type = input.Type.IsQueryable() ? typeof(Queryable) : typeof(Enumerable);
            var expr = Expression.Call(type, "Select", new[] { fn.Parameters[0].Type, fn.ReturnType }, input, fn);

            if (expr.Type == output.Type)
            {
                return(expr);
            }

            if (output.Type.IsArray)
            {
                return(Expression.Call(type, "ToArray", new[] { _outputArg }, expr));
            }

            return(Expression.Call(type, "ToList", new[] { _outputArg }, expr));
        }
示例#2
0
 private Expression Project(Expression input, Expression output)
 {
     var fn = _provider.CreateProjectionFunction(new MapJob(input.Type, output.Type));
     return fn.ReplaceParameters(input);
 }