Welcome on Business Intelligence Blog !!!
This blog is dedicated to Business Intelligence technologies under SAS9 and SQL Server 2005.
| Novembre 2009 | ||||||||||
| L | M | M | J | V | S | D | ||||
| 1 | ||||||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | ||||
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | ||||
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | ||||
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | ||||
| 30 | ||||||||||
|
||||||||||
private
List<TablePath> lookForChilds( TablePath root , TablePath parent)
{
List<TablePath> ltp = new List<TablePath>();
DataTable dt = _database.Tables[parent.TableName,parent.Schema].EnumForeignKeys();
foreach (DataRow dr in dt.Rows)
{
string tableName = dr[1].ToString();
string schemaName = dr[0].ToString();
string fkname = dr[2].ToString();
if (!(tableName.Equals(parent.TableName) &&
schemaName.Equals(parent.Schema))
)
{
log.Info(
"scanning now " + tableName);
TablePath tp = new TablePath();
tp._database = parent._database;
tp._server = parent._server;
tp.TableName = dr[1].ToString();
tp.Schema = schemaName;
tp.ForeignKey = fkname;
tp._childs =
this.lookForChilds(root, tp);
ltp.Add(tp);
}
else
{
log.Info(
"preventing infiniteRecursion on " + tableName);
}
}
return ltp;
}
private void AdaptTablePath(ref TreeNode node, TablePath tablePath)
{
node.Text = tablePath.TableName +
" via < " +tablePath.ForeignKey +" >";
if (tablePath.Childs != null)
{
foreach (TablePath tp in tablePath.Childs)
{
TreeNode childNode = new TreeNode(tp.TableName );
AdaptTablePath(
ref childNode, tp);
node.Nodes.Add(childNode);
}
}
}