コード例 #1
0
        private string TranspileToSQL(string cypherQueryText)
        {
            var parser    = new OpenCypherParser(_logger);
            var queryNode = parser.Parse(cypherQueryText);
            var plan      = LogicalPlan.ProcessQueryTree(
                parser.Parse(cypherQueryText),
                _graphDef,
                _logger);
            var sqlRender = new SQLRenderer(_graphDef, _logger);

            return(sqlRender.RenderPlan(plan));
        }
コード例 #2
0
        private LogicalPlan RunQueryAndDumpTree(IGraphSchemaProvider graphDef, string cypherQueryText)
        {
            var parser    = new OpenCypherParser(_logger);
            var queryNode = parser.Parse(cypherQueryText);
            var planner   = LogicalPlan.ProcessQueryTree(queryNode, graphDef);

            Assert.IsNotNull(planner.StartingOperators);
            Assert.IsNotNull(planner.TerminalOperators);

            // Dump both parse tree and logical plan
            var tree    = queryNode.DumpTree();
            var logical = planner.DumpGraph();

            return(planner);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // To run this program directly after build, in shell, type:
            //   dotnet run bin/Debug/netcoreapp2.1/simple.dll

            var cypherQueryText = @"
                |MATCH (d:device)-[:belongsTo]->(t:tenant)
                |MATCH (d)-[:runs]->(a:app)
                |RETURN t.id as TenantId, a.AppName as AppName, COUNT(d) as DeviceCount
            ".StripMargin();

            Console.WriteLine("Input openCypher Query:");
            Console.WriteLine(cypherQueryText);

            var graphDef = new SimpleProvider();

            var plan      = LogicalPlan.ProcessQueryTree(OpenCypherParser.Parse(cypherQueryText, null), graphDef, null);
            var sqlRender = new SQLRenderer(graphDef, null);
            var tSqlQuery = sqlRender.RenderPlan(plan);

            Console.WriteLine("Output T-SQL Query:");
            Console.WriteLine(tSqlQuery);
        }