Esempio n. 1
0
        internal ElseIfChainer(Chainer prev, IOpenView openView, bool sign)
            : base(prev)
        {
            chainMethod = Text.Method.ElseIfExists;
            CheckNullAndThrow(Arg(() => openView, openView));

            IOpenView query;

            if (openView is ISemantic)
            {
                query = DbMapping.SelectFromSemantic((ISemantic)openView);
            }
            else
            {
                query = openView;
            }

            var view = new View(query);

            if (Exception != null)
            {
                Exception.Extra = String.Format("Check {0} method.", Exception.Method);
                TryThrow();
            }

            Build = BuildViewMethod(view, sign);
        }
Esempio n. 2
0
        internal TableChainer(Chainer prev, IOpenView openView)
            : this(prev)
        {
            IOpenView query = null;

            // SEMQ
            if (openView is ISemantic)
            {
                SetNode(((DbNode)openView).Root);

                if (((ISemantic)openView).IsQuery)
                {
                    query = DbMapping.SelectFromSemantic((ISemantic)openView);
                }
                else if (openView is IFunction)
                {
                    ProcessTableArgument(((IFunction)openView).GetUdf());
                    return;
                }
                // table/view identifier:
                else
                {
                    if (_node.IsSynonym)
                    {
                        if (_node.SynonymQuery is IOpenView)
                        {
                            query = (IOpenView)_node.SynonymQuery;
                        }
                        else
                        {
                            ProcessTableArgument((View)_node.SynonymQuery);
                            return;
                        }
                    }
                    else
                    {
                        ProcessTableArgument(_node.Map.Name);
                        return;
                    }
                }
            }
            // SQL query:
            else
            {
                query = openView;
            }

            Query.AddTableObject(this);

            var tableArgument = query;
            CheckNullAndThrow(Arg(() => tableArgument, tableArgument));
            TryThrow(((Chainer)query).Exception);

            var view = new View(query, Query);
            _table = view;

            Query.AddArguments(view.Query.Arguments.ToArray());

            if (chainException != null)
            {
                chainException.Extra = String.Format("Check {0} method.", chainException.Method);
                TryThrow();
            }

            TableArgument = _table;
        }