Ejemplo n.º 1
0
 public static string GetFragmentType(TSqlFragment Statement)
 {
     String Type = Statement.ToString();
     String[] TypeSplit = Type.Split('.');
     String StmtType = TypeSplit[TypeSplit.Length - 1];
     return (StmtType);
 }
Ejemplo n.º 2
0
        public static string GetFragmentType(TSqlFragment Statement)
        {
            String Type = Statement.ToString();

            String[] TypeSplit = Type.Split('.');
            String   StmtType  = TypeSplit[TypeSplit.Length - 1];

            return(StmtType);
        }
Ejemplo n.º 3
0
        private static List <TableReference> FindTableReferences(TSqlFragment statement)
        {
            var nodeType = statement.ToString().Split(' ')[0];
            var t        = ScriptDomCode.GetType(nodeType, false, true);

            var tables = new List <TableReference>();

            foreach (var p in t.GetProperties())
            {
                var value = TryGetValue(p, statement);
                if (value == null)
                {
                    continue;
                }

                if (value is List <TableReference> )
                {
                    tables.AddRange(value as List <TableReference>);
                    continue;
                }

                if (value is TableReference)
                {
                    tables.Add(value as TableReference);
                    continue;
                }

                //don't move this before is List<TableReference> as they are also TSqlFragments which causes hilarity
                if (value is IEnumerable <TSqlFragment> )
                {
                    foreach (var fragment in value as IEnumerable <TSqlFragment> )
                    {
                        tables.AddRange(FindTableReferences(fragment));
                    }

                    continue;
                }

                if (value is TSqlFragment)
                {
                    tables.AddRange(FindTableReferences(value as TSqlFragment));
                    continue;
                }
            }

            return(tables);
        }
Ejemplo n.º 4
0
        private static List<TableReference> FindTableReferences(TSqlFragment statement)
        {
            var nodeType = statement.ToString().Split(' ')[0];
            var t = ScriptDomCode.GetType(nodeType, false, true);

            var tables = new List<TableReference>();

            foreach (var p in t.GetProperties())
            {
                var value = TryGetValue(p, statement);
                if(value == null)
                    continue;
                
                if (value is List<TableReference>)
                {
                    tables.AddRange(value as List<TableReference>);
                    continue;
                }

                if (value is TableReference)
                {
                    tables.Add(value as TableReference);
                    continue;
                }
                
                //don't move this before is List<TableReference> as they are also TSqlFragments which causes hilarity
                if (value is IEnumerable<TSqlFragment>)
                {
                    foreach (var fragment in value as IEnumerable<TSqlFragment>)
                    {
                        tables.AddRange(FindTableReferences(fragment));
                    }

                    continue;
                }

                if (value is TSqlFragment)
                {
                    tables.AddRange(FindTableReferences(value as TSqlFragment));
                    continue;
                }
            }

            return tables;
        }