<MyDocuments>\Visual Studio 2008\Projects\JRS.Utilities\JRS.Utilities\bin\Debug\JRS.Utilities.dll void Main() { var tables = new string[] { "table1", "table2", "table3", "table4", }; var routine_query = "from d in INFORMATION_SCHEMA.ROUTINES where d.ROUTINE_DEFINITION.Contains( \"{0}\" ) select d"; var queries = from s in tables select string.Format(routine_query, s); StringBuilder sb = new StringBuilder(); int i = 0; sb.AppendLine("//*******************************************"); sb.AppendLine("// Cross reference routines for tables..."); foreach (var table in tables) sb.AppendFormat("// {0}\n", table); sb.AppendLine("//*******************************************"); foreach (var q in queries) { sb.AppendFormat( "{0} q{1} in ({2}){3}", i == 0 ? "from " : "\njoin ", i, q, i == 0 ? string.Empty : string.Format("\non q0.ROUTINE_NAME equals q{0}.ROUTINE_NAME ", i) ); i++; } sb.AppendLine("\n select new { "); sb.AppendLine(" Name = q0.ROUTINE_NAME,"); sb.AppendLine(" DrillDown = new Hyperlinq ("); sb.AppendLine(" QueryLanguage.Expression,"); sb.AppendLine(" string.Format(\"(from x in INFORMATION_SCHEMA.ROUTINES where x.ROUTINE_NAME == \\\"{0}\\\" select x.ROUTINE_DEFINITION).Dump()\", q0.ROUTINE_NAME),"); sb.AppendLine(" \"Show Code\")"); sb.AppendLine(" }"); Console.Write( new Hyperlinq(QueryLanguage.Expression, sb.ToString(), "Exec") ); }