private Node <Nodes.Column> GetColumnNode(Node <Nodes.Database> databaseNode, TSqlObject sqlColumn) { var sqlTable = sqlColumn.GetParent(); if (sqlTable == null) { return(null); } var tableName = sqlTable.Name.ToString(); var columnName = sqlColumn.Name.ToString(); var query = _graphClient.Cypher .Start(new { database = databaseNode.Reference }) .Match("database-[:DATABASE_CONTAINS_TABLE]->table-[:TABLE_CONTAINS_COLUMN]->column") .Where((Nodes.Table table, Nodes.Column column) => table.Id == tableName && column.Id == columnName) .Return <Node <Nodes.Column> >("column"); var results = query.Results.ToList(); return(results.Count == 1 ? results.First() : null); }
private void ChangeCreateIndexOperationalProps(DeploymentPlanContributorContext context, IList <IndexOption> options) { DeploymentStep nextStep = context.PlanHandle.Head; // Loop through all steps in the deployment plan bool foundMainSection = false; while (nextStep != null) { DeploymentStep currentStep = nextStep; nextStep = currentStep.Next; // We only want to analyze the main part of the deployment script - we'll skip // any steps until we pass the end of the predeployment section, and stop once // we hit the start of the postdeployment section if (currentStep is EndPreDeploymentScriptStep) { foundMainSection = true; continue; } if (!foundMainSection) { // Haven't gotten past predeployment yet continue; } if (currentStep is BeginPostDeploymentScriptStep) { break; } // We need to care about CreateElementSteps and AlterElementSteps for Indexes. DeploymentScriptDomStep domStep = currentStep as DeploymentScriptDomStep; TSqlObject elementObject = null; if (domStep is CreateElementStep) { elementObject = ((CreateElementStep)domStep).SourceElement; } else if (domStep is AlterElementStep) { elementObject = ((AlterElementStep)domStep).SourceElement; } if (elementObject != null) { if (Index.TypeClass.Equals(elementObject.ObjectType) && !(View.TypeClass.Equals(elementObject.GetParent().ObjectType))) { TSqlFragment fragment = domStep.Script; IndexStatementVisitor visitor = new IndexStatementVisitor(options); fragment.Accept(visitor); } } } }