• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# InternalTrees.Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Data.Entity.Core.Query.InternalTrees.Node的典型用法代码示例。如果您正苦于以下问题:C# Node类的具体用法?C# Node怎么用?C# Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Node类属于System.Data.Entity.Core.Query.InternalTrees命名空间,在下文中一共展示了Node类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PatternMatchRule

 /// <summary>
 ///     Basic constructor
 /// </summary>
 /// <param name="pattern"> The pattern to look for </param>
 /// <param name="processDelegate"> The callback to invoke when such a pattern is identified </param>
 internal PatternMatchRule(Node pattern, ProcessNodeDelegate processDelegate)
     : base(pattern.Op.OpType, processDelegate)
 {
     Debug.Assert(pattern != null, "null pattern");
     Debug.Assert(pattern.Op != null, "null pattern Op");
     m_pattern = pattern;
 }
开发者ID:junxy,项目名称:entityframework,代码行数:12,代码来源:PatternMatchRule.cs


示例2: VisitDefault

        protected override Node VisitDefault(Node n)
        {
            var negated = _negated;

            switch (n.Op.OpType)
            {
                case OpType.Not:
                    _negated = !_negated;
                    n = base.VisitDefault(n);
                    break;
                case OpType.Or:
                    n = HandleOr(n);
                    break;
                case OpType.And:
                    n = base.VisitDefault(n);
                    break;
                case OpType.EQ:
                    _negated = false;
                    n = HandleEQ(n, negated);
                    break;
                case OpType.NE:
                    n = HandleNE(n);
                    break;
                default:
                    _negated = false;
                    n = base.VisitDefault(n);
                    break;
            }

            _negated = negated;

            return n;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:33,代码来源:NullSemantics.cs


示例3: ProcessSetOpOverEmptySet

        /// <summary>
        ///     Process a SetOp when one of the inputs is an emptyset. 
        /// 
        ///     An emptyset is represented by a Filter(X, ConstantPredicate)
        ///     where the ConstantPredicate has a value of "false"
        /// 
        ///     The general rules are
        ///     UnionAll(X, EmptySet) => X
        ///     UnionAll(EmptySet, X) => X
        ///     Intersect(EmptySet, X) => EmptySet
        ///     Intersect(X, EmptySet) => EmptySet
        ///     Except(EmptySet, X) => EmptySet
        ///     Except(X, EmptySet) => X
        /// 
        ///     These rules then translate into 
        ///     UnionAll: return the non-empty input
        ///     Intersect: return the empty input
        ///     Except: return the "left" input
        /// </summary>
        /// <param name="context"> Rule processing context </param>
        /// <param name="setOpNode"> the current setop tree </param>
        /// <param name="filterNodeIndex"> Index of the filter node in the setop </param>
        /// <param name="newNode"> transformed subtree </param>
        /// <returns> transformation status </returns>
        private static bool ProcessSetOpOverEmptySet(RuleProcessingContext context, Node setOpNode, out Node newNode)
        {
            var leftChildIsEmptySet = context.Command.GetExtendedNodeInfo(setOpNode.Child0).MaxRows == RowCount.Zero;
            var rightChildIsEmptySet = context.Command.GetExtendedNodeInfo(setOpNode.Child1).MaxRows == RowCount.Zero;

            if (!leftChildIsEmptySet
                && !rightChildIsEmptySet)
            {
                newNode = setOpNode;
                return false;
            }

            int indexToReturn;
            var setOp = (SetOp)setOpNode.Op;
            if (!rightChildIsEmptySet && setOp.OpType == OpType.UnionAll
                ||
                !leftChildIsEmptySet && setOp.OpType == OpType.Intersect)
            {
                indexToReturn = 1;
            }
            else
            {
                indexToReturn = 0;
            }

            newNode = setOpNode.Children[indexToReturn];

            var trc = (TransformationRulesContext)context;
            foreach (var kv in setOp.VarMap[indexToReturn])
            {
                trc.AddVarMapping(kv.Key, kv.Value);
            }
            return true;
        }
开发者ID:junxy,项目名称:entityframework,代码行数:58,代码来源:SetOpRules.cs


示例4: ProcessSimplifyCase

        /// <summary>
        ///     We perform the following simple transformation for CaseOps. If every single
        ///     then/else expression in the CaseOp is equivalent, then we can simply replace
        ///     the Op with the first then/expression. Specifically,
        ///     case when w1 then t1 when w2 then t2 ... when wn then tn else e end
        ///     => t1
        ///     assuming that t1 is equivalent to t2 is equivalent to ... to e
        /// </summary>
        /// <param name="context"> Rule Processing context </param>
        /// <param name="caseOpNode"> The current subtree for the CaseOp </param>
        /// <param name="newNode"> the (possibly) modified subtree </param>
        /// <returns> true, if we performed any transformations </returns>
        private static bool ProcessSimplifyCase(RuleProcessingContext context, Node caseOpNode, out Node newNode)
        {
            var caseOp = (CaseOp)caseOpNode.Op;
            newNode = caseOpNode;

            //
            // Can I collapse the entire case-expression into a single expression - yes, 
            // if all the then/else clauses are the same expression
            //
            if (ProcessSimplifyCase_Collapse(caseOpNode, out newNode))
            {
                return true;
            }

            //
            // Can I remove any unnecessary when-then pairs ?
            //
            if (ProcessSimplifyCase_EliminateWhenClauses(context, caseOp, caseOpNode, out newNode))
            {
                return true;
            }

            // Nothing else I can think of
            return false;
        }
开发者ID:junxy,项目名称:entityframework,代码行数:37,代码来源:ScalarOpRules.cs


示例5: HandleOr

        private Node HandleOr(Node n)
        {
            // Check for the pattern '(varRef IS NULL) OR expression'.
            var isNullNode =
                n.Child0.Op.OpType == OpType.IsNull
                    ? n.Child0
                    : null;

            if (isNullNode == null
                || isNullNode.Child0.Op.OpType != OpType.VarRef)
            {
                return base.VisitDefault(n);
            }

            // Mark 'variable' as not nullable while 'expression' is visited.
            Var variable = ((VarRefOp)isNullNode.Child0.Op).Var;

            var nullable = _variableNullabilityTable[variable];
            _variableNullabilityTable[variable] = false;

            n.Child1 = VisitNode(n.Child1);

            _variableNullabilityTable[variable] = nullable;

            return n;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:26,代码来源:NullSemantics.cs


示例6: Match

 private bool Match(Node pattern, Node original)
 {
     if (pattern.Op.OpType
         == OpType.Leaf)
     {
         return true;
     }
     if (pattern.Op.OpType
         != original.Op.OpType)
     {
         return false;
     }
     if (pattern.Children.Count
         != original.Children.Count)
     {
         return false;
     }
     for (var i = 0; i < pattern.Children.Count; i++)
     {
         if (!Match(pattern.Children[i], original.Children[i]))
         {
             return false;
         }
     }
     return true;
 }
开发者ID:junxy,项目名称:entityframework,代码行数:26,代码来源:PatternMatchRule.cs


示例7: VisitChildren

 /// <summary>
 ///     Visit the children of this Node
 /// </summary>
 /// <param name="n"> The Node that references the Op </param>
 protected virtual void VisitChildren(Node n)
 {
     foreach (var chi in n.Children)
     {
         VisitNode(chi);
     }
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:BasicOpVisitor.cs


示例8: ApplyRulesToNode

        private static bool ApplyRulesToNode(
            RuleProcessingContext context, ReadOnlyCollection<ReadOnlyCollection<Rule>> rules, Node currentNode, out Node newNode)
        {
            newNode = currentNode;

            // Apply any pre-rule delegates
            context.PreProcess(currentNode);

            foreach (var r in rules[(int)currentNode.Op.OpType])
            {
                if (!r.Match(currentNode))
                {
                    continue;
                }

                // Did the rule modify the subtree?
                if (r.Apply(context, currentNode, out newNode))
                {
                    // The node has changed; don't try to apply any more rules
                    context.PostProcess(newNode, r);
                    return true;
                }
                else
                {
                    Debug.Assert(newNode == currentNode, "Liar! This rule should have returned 'true'");
                }
            }

            context.PostProcess(currentNode, null);
            return false;
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:31,代码来源:RuleProcessor.cs


示例9: VisitChildrenReverse

 /// <summary>
 ///     Visit the children of this Node. but in reverse order
 /// </summary>
 /// <param name="n"> The current node </param>
 protected virtual void VisitChildrenReverse(Node n)
 {
     for (var i = n.Children.Count - 1; i >= 0; i--)
     {
         VisitNode(n.Children[i]);
     }
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:BasicOpVisitor.cs


示例10: ReMap

        internal Node ReMap(Node node, Dictionary<Var, Node> varMap)
        {
            PlanCompiler.Assert(node.Op.IsScalarOp, "Expected a scalarOp: Found " + Dump.AutoString.ToString(node.Op.OpType));

            // Replace varRefOps by the corresponding expression in the map, if any
            if (node.Op.OpType
                == OpType.VarRef)
            {
                var varRefOp = node.Op as VarRefOp;
                Node newNode = null;
                if (varMap.TryGetValue(varRefOp.Var, out newNode))
                {
                    newNode = Copy(newNode);
                    return newNode;
                }
                else
                {
                    return node;
                }
            }

            // Simply process the result of the children.
            for (var i = 0; i < node.Children.Count; i++)
            {
                node.Children[i] = ReMap(node.Children[i], varMap);
            }

            // We may have changed something deep down
            Command.RecomputeNodeInfo(node);
            return node;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:31,代码来源:TransformationRulesContext.cs


示例11: Copy

 internal static Node Copy(Command cmd, Node n, out VarMap varMap)
 {
     var oc = new OpCopier(cmd);
     var newNode = oc.CopyNode(n);
     varMap = oc.m_varMap;
     return newNode;
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:OpCopier.cs


示例12: ProcessDistinctOpOfKeys

        /// <summary>
        ///     If the DistinctOp includes all all the keys of the input, than it is unnecessary.
        ///     Distinct (X, distinct_keys) -> Project( X, distinct_keys) where distinct_keys includes all keys of X.
        /// </summary>
        /// <param name="context"> Rule processing context </param>
        /// <param name="n"> current subtree </param>
        /// <param name="newNode"> transformed subtree </param>
        /// <returns> transformation status </returns>
        private static bool ProcessDistinctOpOfKeys(RuleProcessingContext context, Node n, out Node newNode)
        {
            var command = context.Command;

            var nodeInfo = command.GetExtendedNodeInfo(n.Child0);

            var op = (DistinctOp)n.Op;

            //If we know the keys of the input and the list of distinct keys includes them all, omit the distinct
            if (!nodeInfo.Keys.NoKeys
                && op.Keys.Subsumes(nodeInfo.Keys.KeyVars))
            {
                var newOp = command.CreateProjectOp(op.Keys);

                //Create empty vardef list
                var varDefListOp = command.CreateVarDefListOp();
                var varDefListNode = command.CreateNode(varDefListOp);

                newNode = command.CreateNode(newOp, n.Child0, varDefListNode);
                return true;
            }

            //Otherwise return the node as is
            newNode = n;
            return false;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:34,代码来源:DistinctOpRules.cs


示例13: ProcessSingleRowOpOverAnything

        // <summary>
        // Convert a
        // SingleRowOp(X) => X
        // if X produces at most one row
        // </summary>
        // <param name="context"> Rule Processing context </param>
        // <param name="singleRowNode"> Current subtree </param>
        // <param name="newNode"> transformed subtree </param>
        // <returns> Transformation status </returns>
        private static bool ProcessSingleRowOpOverAnything(RuleProcessingContext context, Node singleRowNode, out Node newNode)
        {
            newNode = singleRowNode;
            var trc = (TransformationRulesContext)context;
            var childNodeInfo = context.Command.GetExtendedNodeInfo(singleRowNode.Child0);

            // If the input to this Op can produce at most one row, then we don't need the
            // singleRowOp - simply return the input
            if (childNodeInfo.MaxRows
                <= RowCount.One)
            {
                newNode = singleRowNode.Child0;
                return true;
            }

            //
            // if the current node is a FilterOp, then try and determine if the FilterOp
            // produces one row at most
            //
            if (singleRowNode.Child0.Op.OpType
                == OpType.Filter)
            {
                var predicate = new Predicate(context.Command, singleRowNode.Child0.Child1);
                if (predicate.SatisfiesKey(childNodeInfo.Keys.KeyVars, childNodeInfo.Definitions))
                {
                    childNodeInfo.MaxRows = RowCount.One;
                    newNode = singleRowNode.Child0;
                    return true;
                }
            }

            // we couldn't do anything
            return false;
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:43,代码来源:SingleRowOpRules.cs


示例14: Visit

        // <summary>
        // Determines whether the var or a property of the var (if the var is defined as a NewRecord)
        // is defined exclusively over a single group aggregate. If so, it registers it as such with the
        // group aggregate var info manager.
        // </summary>
        public override void Visit(VarDefOp op, Node n)
        {
            VisitDefault(n);

            var definingNode = n.Child0;
            var definingNodeOp = definingNode.Op;

            GroupAggregateVarInfo referencedVarInfo;
            Node templateNode;
            bool isUnnested;
            if (GroupAggregateVarComputationTranslator.TryTranslateOverGroupAggregateVar(
                definingNode, true, _command, _groupAggregateVarInfoManager, out referencedVarInfo, out templateNode, out isUnnested))
            {
                _groupAggregateVarInfoManager.Add(op.Var, referencedVarInfo, templateNode, isUnnested);
            }
            else if (definingNodeOp.OpType
                     == OpType.NewRecord)
            {
                var newRecordOp = (NewRecordOp)definingNodeOp;
                for (var i = 0; i < definingNode.Children.Count; i++)
                {
                    var argumentNode = definingNode.Children[i];
                    if (GroupAggregateVarComputationTranslator.TryTranslateOverGroupAggregateVar(
                        argumentNode, true, _command, _groupAggregateVarInfoManager, out referencedVarInfo, out templateNode, out isUnnested))
                    {
                        _groupAggregateVarInfoManager.Add(op.Var, referencedVarInfo, templateNode, isUnnested, newRecordOp.Properties[i]);
                    }
                }
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:35,代码来源:GroupAggregateRefComputingVisitor.cs


示例15: ComputeHashValue

 /// <summary>
 ///     Compute the hash value for this node
 /// </summary>
 internal override void ComputeHashValue(Command cmd, Node n)
 {
     base.ComputeHashValue(cmd, n);
     m_hashValue = (m_hashValue << 4) ^ GetHashValue(Definitions);
     m_hashValue = (m_hashValue << 4) ^ GetHashValue(Keys.KeyVars);
     return;
 }
开发者ID:hallco978,项目名称:entityframework,代码行数:10,代码来源:ExtendedNodeInfo.cs


示例16: HasKeyReferences

        /// <summary>
        ///     Determines whether any var from a given list of keys is referenced by any of defining node's right relatives,
        ///     with the exception of the relatives brunching at the given targetJoinNode.
        /// </summary>
        /// <param name="keys"> A list of vars to check for </param>
        /// <param name="definingNode"> The node considered to be the defining node </param>
        /// <param name="targetJoinNode"> The relatives branching at this node are skipped </param>
        /// <returns> False, only it can determine that not a single var from a given list of keys is referenced by any of defining node's right relatives, with the exception of the relatives brunching at the given targetJoinNode. </returns>
        internal bool HasKeyReferences(VarVec keys, Node definingNode, Node targetJoinNode)
        {
            var currentChild = definingNode;
            Node parent;
            var continueUp = true;

            while (continueUp & m_nodeToParentMap.TryGetValue(currentChild, out parent))
            {
                if (parent != targetJoinNode)
                {
                    // Check the parent
                    if (HasVarReferencesShallow(parent, keys, m_nodeToSiblingNumber[currentChild], out continueUp))
                    {
                        return true;
                    }

                    //Check all the siblings to the right
                    for (var i = m_nodeToSiblingNumber[currentChild] + 1; i < parent.Children.Count; i++)
                    {
                        if (parent.Children[i].GetNodeInfo(m_command).ExternalReferences.Overlaps(keys))
                        {
                            return true;
                        }
                    }
                }
                currentChild = parent;
            }
            return false;
        }
开发者ID:hallco978,项目名称:entityframework,代码行数:37,代码来源:VarRefManager.cs


示例17: PatternMatchRule

 /// <summary>
 ///     Basic constructor
 /// </summary>
 /// <param name="pattern"> The pattern to look for </param>
 /// <param name="processDelegate"> The callback to invoke when such a pattern is identified </param>
 internal PatternMatchRule(Node pattern, ProcessNodeDelegate processDelegate)
     : base(pattern.Op.OpType, processDelegate)
 {
     DebugCheck.NotNull(pattern);
     DebugCheck.NotNull(pattern.Op);
     m_pattern = pattern;
 }
开发者ID:christiandpena,项目名称:entityframework,代码行数:12,代码来源:PatternMatchRule.cs


示例18: RemapNode

 // <summary>
 // Update vars in just this node (and not the entire subtree)
 // Does *not* recompute the nodeinfo - there are at least some consumers of this
 // function that do not want the recomputation - transformation rules, for example
 // </summary>
 // <param name="node"> current node </param>
 internal virtual void RemapNode(Node node)
 {
     if (m_varMap.Count == 0)
     {
         return;
     }
     VisitNode(node);
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:VarRemapper.cs


示例19: AssertArity

 protected static void AssertArity(Node n)
 {
     if (n.Op.Arity
         != Op.ArityVarying)
     {
         AssertArity(n, n.Op.Arity);
     }
 }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:8,代码来源:BasicValidator.cs


示例20: Copy

 /// <summary>
 /// Equivalent to OpCopier.Copy, only in addition it keeps track of the defining subtrees
 /// of collection vars defined in the subtree rooted at the copy of the input node n.
 /// </summary>
 /// <param name="cmd"></param>
 /// <param name="n"></param>
 /// <param name="varMap"></param>
 /// <param name="newCollectionVarDefinitions"></param>
 /// <returns></returns>
 internal static Node Copy(Command cmd, Node n, out VarMap varMap, out Dictionary<Var, Node> newCollectionVarDefinitions)
 {
     var oc = new OpCopierTrackingCollectionVars(cmd);
     var newNode = oc.CopyNode(n);
     varMap = oc.m_varMap;
     newCollectionVarDefinitions = oc.m_newCollectionVarDefinitions;
     return newNode;
 }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:17,代码来源:OpCopierTrackingCollectionVars.cs



注:本文中的System.Data.Entity.Core.Query.InternalTrees.Node类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# InternalTrees.RuleProcessingContext类代码示例发布时间:2022-05-26
下一篇:
C# InternalTrees.Command类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap