Exemplo n.º 1
0
        public static Func <IQueryable, IQueryable> BuildSelectFunc(Type elementType, List <String> selectClauses)
        {
            var propSigs   = selectClauses.Select(sc => new PropertySignature(elementType, sc)).ToList();
            var dti        = DynamicTypeInfo.FindOrCreate(propSigs.Select(ps => ps.Name), propSigs.Select(ps => ps.ReturnType));
            var lambdaExpr = CreateNewLambda(dti, propSigs);
            var method     = TypeFns.GetMethodByExample((IQueryable <String> q) => q.Select(s => s.Length), elementType, dti.DynamicType);
            var func       = BuildIQueryableFunc(elementType, method, lambdaExpr);

            return(func);
        }
Exemplo n.º 2
0
        public static IQueryable ApplySelect(IQueryable source, Type elementType, SelectClause selectClause)
        {
            var propSigs   = selectClause.Properties;
            var dti        = DynamicTypeInfo.FindOrCreate(propSigs.Select(ps => ps.Name), propSigs.Select(ps => ps.ReturnType));
            var lambdaExpr = CreateNewLambda(dti, propSigs);
            var method     = TypeFns.GetMethodByExample((IQueryable <String> q) => q.Select(s => s.Length), elementType, dti.DynamicType);
            var func       = BuildIQueryableFunc(elementType, method, lambdaExpr);

            return(func(source));
        }