Ejemplo n.º 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));
        }
Ejemplo n.º 2
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);
        }