internal static ProviderCommandInfo Create(Command command, System.Data.Entity.Core.Query.InternalTrees.Node node) { PhysicalProjectOp op = node.Op as PhysicalProjectOp; System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(op != null, "Expected root Op to be a physical Project"); DbCommandTree commandTree = CTreeGenerator.Generate(command, node); DbQueryCommandTree queryCommandTree = commandTree as DbQueryCommandTree; System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(queryCommandTree != null, "null query command tree"); CollectionType edmType = TypeHelpers.GetEdmType <CollectionType>(queryCommandTree.Query.ResultType); System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(TypeSemantics.IsRowType(edmType.TypeUsage), "command rowtype is not a record"); ProviderCommandInfoUtils.BuildOutputVarMap(op, edmType.TypeUsage); return(new ProviderCommandInfo(commandTree)); }
/// <summary> /// Creates a ProviderCommandInfo for the given node. /// This method should be called when the keys, foreign keys and sort keys are known ahead of time. /// Typically it is used when the original command is factored into multiple commands. /// </summary> /// <param name="command">The owning command, used for creating VarVecs, etc</param> /// <param name="node">The root of the sub-command for which a ProviderCommandInfo should be generated</param> /// <param name="children">A list of ProviderCommandInfos that were created for the child sub-commands.</param> /// <returns>The resulting ProviderCommandInfo</returns> internal static ProviderCommandInfo Create( Command command, Node node, List <ProviderCommandInfo> children) { PhysicalProjectOp projectOp = node.Op as PhysicalProjectOp; PlanCompiler.Assert(projectOp != null, "Expected root Op to be a physical Project"); // build up the CQT DbCommandTree ctree = CTreeGenerator.Generate(command, node); DbQueryCommandTree cqtree = ctree as DbQueryCommandTree; PlanCompiler.Assert(cqtree != null, "null query command tree"); // Get the rowtype for the result cqt md.CollectionType collType = TypeHelpers.GetEdmType <md.CollectionType>(cqtree.Query.ResultType); PlanCompiler.Assert(md.TypeSemantics.IsRowType(collType.TypeUsage), "command rowtype is not a record"); // Build up a mapping from Vars to the corresponding output property/column Dictionary <Var, md.EdmProperty> outputVarMap = BuildOutputVarMap(projectOp, collType.TypeUsage); return(new ProviderCommandInfo(ctree, children)); }