Ejemplo n.º 1
0
        /// <summary>
        /// Sets the inner node of the graph instance.
        /// </summary>
        /// <param name="context">A semantic context.</param>
        /// <param name="innerNode">The inner node.</param>
        protected void SetInnerNode(SemqContext context, DbNode innerNode)
        {
            if (context == null)
            {
                throw new QueryTalkException(this, QueryTalkExceptionType.NullArgumentInnerException,
                                             "context = null", "DbGraphBase.SetInnerNode");
            }

            _innerNode = innerNode;
            context.SetGraphIndex(_innerNode);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the inner node of the graph instance.
        /// </summary>
        /// <param name="context">A semantic context.</param>
        protected DbNode GetInnerNode(SemqContext context)
        {
            if (context == null)
            {
                throw new QueryTalkException(this, QueryTalkExceptionType.NullArgumentInnerException,
                                             "context = null", "DbGraphBase.GetInnerNode");
            }

            if (_innerNode != null)
            {
                return(_innerNode);
            }
            else
            {
                var innerNode = InnerGraph.Subject;
                context.SetGraphIndex(innerNode);
                return(innerNode);
            }
        }
Ejemplo n.º 3
0
        internal static void TranslateGraphNode(IGraph graph, SemqContext context, DbNode predecessor, DbNode node, bool isLeafNode = false)
        {
            var isSubject = (predecessor == null);

            node = node.Root;
            context.SetGraphIndex(node);

            Chainer  translatedNode;
            Designer root;

            if (isSubject)
            {
                root = new InternalRoot(node);
            }
            else
            {
                root = context.TranslatedGraph.GetRoot();
                node.IsFinalizeable = false;
            }

            // translate node only
            //   important:
            //     The node should be translated before the graph processing begins in order that to obtain the appropriate index.
            translatedNode = ((ISemantic)node).Translate(context, predecessor);

            StringBuilder nodeTableVar = null;

            // create table variable storage except for the last leaf node which does not need a table variable
            if (!isLeafNode)
            {
                TranslateGraphDeclareTable(node, root, out nodeTableVar);
            }

            // finish the node query translation as part of a graph
            if (isSubject)
            {
                TranslateGraphSubject(context, node, root, translatedNode, nodeTableVar);
            }
            else
            {
                TranslateGraphRelated(graph, context, predecessor, node, translatedNode, nodeTableVar);
            }
        }