Question

Due to a lack of documentation surrounding the use of the TSql100Parser class is there any way I can determine the parent of a particular node?

I am using Microsoft.Data.Schema.ScriptDom.Sql and Microsoft.Data.Schema.ScriptDom assemblies to do the parsing for me.

Example:

static void __processExpression( Expression expr ) {
    if (expr is ParenthesisExpression) {
        __processExpression( (expr as ParenthesisExpression).Expression );
    }
    else if (expr is BinaryExpression) {
        __processBinaryExpression( expr as BinaryExpression );
    }
    else if (expr is Literal) {
         Literal lit = (expr as Literal);
         ISqlScriptFragment parent = lit.Parent; // <----- this is what I want to do
    }           

If this isn't possible I can just pass in the parent as an additional parameter to the __processExpression() method, but I would like to avoid this if there is an official way of doing it.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top