/// <summary> /// Read the current database from the server; /// </summary> /// <returns>the databases</returns> public SqlSysDatabase ReadCurrentDatbase() { var sqlTransConnection = this.EnsureOpenTransConnection(); using (var command = sqlTransConnection.SqlCommand(System.Data.CommandType.Text, SqlSysDatabase.SELECTCurrentStatement)) { var sqlResults = SqlUtility.ExecuteReader(command, false, false); var result = EntityFlexible.ConvertFromSqlResult <SqlSysDatabase>(nameof(SqlSysDatabase), sqlResults.First(), SqlSysDatabase.Factory).FirstOrDefault(); this.DatabaseById[result.database_id] = result; this.CurrentDatabase = result; return(result); } }
/// <summary> /// Read the objects. /// </summary> /// <param name="db">the database if null the current or the connnection db is used - null is good</param> /// <returns>the database</returns> public SqlSysDatabase ReadAllFromDatabase(SqlSysDatabase db = null) { if (db == null) { db = this.CurrentDatabase; } if (db == null) { db = this.ReadCurrentDatbase(); } if (db != null) { var sqlTransConnection = this.EnsureOpenTransConnection(); db.ReadAll(sqlTransConnection); } return(db); }