Ejemplo n.º 1
0
        internal string TryGetTableAlias(string alias)
        {
            TableChainer ctable = GetPrevTable(Statement.StatementIndex);

            if (alias == null)
            {
                if (ctable != null && ctable is FromChainer)
                {
                    return(ctable.Alias.Name);
                }
            }
            else
            {
                while (ctable != null)
                {
                    if (ctable != null && ctable.Alias.Name == alias)
                    {
                        return(alias);
                    }

                    ctable = ctable.GetPrevTable(Statement.StatementIndex);
                }
            }

            Throw(QueryTalkExceptionType.TargetTableNotFound, String.Format("target alias = {0}", alias ?? Text.ClrNull));

            return(null);
        }
Ejemplo n.º 2
0
        // Get target table by alias.
        //   anticipated:
        //     If alias is not given, then the target is the first table - which must be FromChainer.
        private TableChainer GetTarget(ref string alias)
        {
            TableChainer ctable = GetPrevTable(Statement.StatementIndex);

            if (alias == null)
            {
                if (ctable is FromChainer)
                {
                    alias = ctable.Alias.Name;
                    return(ctable);
                }

                return(null);
            }

            while (ctable != null)
            {
                // case-sensitive comparison
                if (ctable.Alias.Name.EqualsCS(alias))
                {
                    return(ctable);
                }

                ctable = ctable.GetPrevTable(Statement.StatementIndex);
            }

            return(null);  // not found
        }