public void OrderBy(String name, bool ascent)
        {
            FieldInfo f = QueryImpl.lookupField(cls, name);
            OrderNode node;

            if (f == null)
            {
                MethodInfo m = QueryImpl.lookupMethod(cls, name, QueryImpl.defaultProfile);
                if (m == null)
                {
                    throw new CodeGeneratorException("No such field " + name + " in class " + cls);
                }
                else
                {
                    node = new OrderNode(m);
                }
            }
            else
            {
                node = new OrderNode(f);
            }
            node.ascent = ascent;
            if (query.order == null)
            {
                query.order = node;
            }
            else
            {
                OrderNode last;
                for (last = query.order; last.next != null; last = last.next)
                {
                    ;
                }
                last.next = node;
            }
        }
        public Code Invoke(Code baseExpr, String name, params Code[] arguments)
        {
            Type[] profile = new Type[arguments.Length];
            Node[] args    = new Node[arguments.Length];
            for (int i = 0; i < profile.Length; i++)
            {
                Node arg = (Node)arguments[i];
                args[i] = arg;
                Type argType;
                switch (arg.type)
                {
                case NodeType.tpInt:
                    argType = typeof(long);
                    break;

                case NodeType.tpReal:
                    argType = typeof(double);
                    break;

                case NodeType.tpStr:
                    argType = typeof(String);
                    break;

                case NodeType.tpDate:
                    argType = typeof(DateTime);
                    break;

                case NodeType.tpBool:
                    argType = typeof(bool);
                    break;

                case NodeType.tpObj:
                    argType = arg.Type;
                    break;

                case NodeType.tpArrayBool:
                    argType = typeof(bool[]);
                    break;

                case NodeType.tpArrayChar:
                    argType = typeof(char[]);
                    break;

                case NodeType.tpArrayInt1:
                    argType = typeof(sbyte[]);
                    break;

                case NodeType.tpArrayInt2:
                    argType = typeof(short[]);
                    break;

                case NodeType.tpArrayInt4:
                    argType = typeof(int[]);
                    break;

                case NodeType.tpArrayInt8:
                    argType = typeof(long[]);
                    break;

                case NodeType.tpArrayUInt1:
                    argType = typeof(byte[]);
                    break;

                case NodeType.tpArrayUInt2:
                    argType = typeof(ushort[]);
                    break;

                case NodeType.tpArrayUInt4:
                    argType = typeof(uint[]);
                    break;

                case NodeType.tpArrayUInt8:
                    argType = typeof(ulong[]);
                    break;

                case NodeType.tpArrayReal4:
                    argType = typeof(float[]);
                    break;

                case NodeType.tpArrayReal8:
                    argType = typeof(double[]);
                    break;

                case NodeType.tpArrayStr:
                    argType = typeof(String[]);
                    break;

                case NodeType.tpArrayObj:
                    argType = typeof(Object[]);
                    break;

                default:
                    throw new CodeGeneratorException("Invalid method argument type");
                }
                profile[i] = argType;
            }
            Type       scope = (baseExpr == null) ? cls : ((Node)baseExpr).Type;
            MethodInfo mth   = QueryImpl.lookupMethod(scope, name, profile);

            if (mth == null)
            {
                throw new CodeGeneratorException("MethodInfo " + name + " not found in class " + scope);
            }
            return(new InvokeNode((Node)baseExpr, mth, args));
        }