/// <summary> /// pulls out a list of databases on the server as an enumerable; /// </summary> public IEnumerable <SqlDbInfo> EnumerateChildren(bool fetchDetails = false) { // create a new connection using the connection string: using (var conn = CreateConnection()) { // open and query for databases: conn.Open(); // get the list of databases: var tbl = conn.GetSchema("Databases"); // enumerate the databases and create a DBInfo for each row: foreach (DataRow row in tbl.Select("1=1", "database_name ASC")) { // add the db-info to the databases collection. SqlDbInfo info = null; try { info = new SqlDbInfo(this, row.Field <string>("database_name"), fetchDetails); } catch (Exception e) { System.Diagnostics.Debug.Print(e.ToString()); } if (info != null) { yield return(info); } } } }
/// <summary> /// construct the table info /// </summary> /// <param name="db"> /// the database the table is from /// </param> /// <param name="tableName"> /// the name of the table /// </param> /// <param name="fetchDetails"> /// should the details (column info) be looked up for the table? /// </param> public SqlDbTableInfo(SqlDbInfo db, string tableName, bool fetchDetails = false) { this.Database = db; this.TableName = tableName; this.RowCount = CountRows(); if (fetchDetails) { DetailsTask = Task.Run(() => GetDetails()); } else { DetailsTask = Task.Run(() => { }); } }