/// <summary> /// Read the schemas from the database; /// </summary> /// <param name="sqlTransConnection">the TransConnection.</param> /// <returns>the tables</returns> public List <SqlSysSchema> ReadSchemas(SqlTransConnection sqlTransConnection) { using (var command = sqlTransConnection.SqlCommand(System.Data.CommandType.Text, SqlSysSchema.SELECTStatement)) { var sqlResults = SqlUtility.ExecuteReader(command, false, false); var result = EntityFlexible.ConvertFromSqlResult <SqlSysSchema>(nameof(SqlSysSchema), sqlResults.First(), SqlSysSchema.Factory); result.ForEach((item) => { this.SchemaById[item.schema_id] = item; }); return(result); } }
/// <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 types from the database. /// </summary> /// <param name="sqlTransConnection">the TransConnection.</param> /// <returns>the columns.</returns> public List <SqlSysType> ReadTypes(SqlTransConnection sqlTransConnection) { using (var command = sqlTransConnection.SqlCommand(System.Data.CommandType.Text, SqlSysType.SELECTStatement)) { var sqlResults = SqlUtility.ExecuteReader(command, false, false); var result = EntityFlexible.ConvertFromSqlResult <SqlSysType>(nameof(SqlSysType), sqlResults.First(), SqlSysType.Factory); result.ForEach((item) => { this.Types.Add(item); this.TypesByUserId[item.user_type_id] = item; }); return(result); } }
/// <summary> /// Read the server info from the server; /// </summary> /// <returns>the server - null if no rights</returns> public SqlSysServer ReadServer() { var sqlTransConnection = this.EnsureOpenTransConnection(); try { using (var command = sqlTransConnection.SqlCommand(System.Data.CommandType.Text, SqlSysServer.SELECTStatment)) { var sqlResults = SqlUtility.ExecuteReader(command, false, false); var result = EntityFlexible.ConvertFromSqlResult <SqlSysServer>(nameof(SqlSysServer), sqlResults.First(), SqlSysServer.Factory).FirstOrDefault(); this.CurrentServer = result; return(result); } } catch { } return(null); }
/// <summary> /// Read the index from the database. /// </summary> /// <param name="sqlTransConnection">the TransConnection.</param> /// <returns>the columns.</returns> public List <SqlSysForeignKey> ReadForeignKey(SqlTransConnection sqlTransConnection) { using (var command = sqlTransConnection.SqlCommand(System.Data.CommandType.Text, SqlSysForeignKey.SELECTStatement)) { var sqlResults = SqlUtility.ExecuteReader(command, false, false); var result = EntityFlexible.ConvertFromSqlResult <SqlSysForeignKey>(nameof(SqlSysForeignKey), sqlResults.First(), SqlSysForeignKey.Factory); result.ForEach((item) => { { var obj = this.AllObjectsById.GetValueOrDefault(item.object_id); if (obj != null) { obj.GetForeignKeys().Add(item); } } }); return(result); } }
/// <summary> /// Read the IndexColumn from the database. /// </summary> /// <param name="sqlTransConnection">the TransConnection.</param> /// <returns>the columns.</returns> public List <SqlSysIndexColumn> ReadIndexColumn(SqlTransConnection sqlTransConnection) { using (var command = sqlTransConnection.SqlCommand(System.Data.CommandType.Text, SqlSysIndexColumn.SELECTStatement)) { var sqlResults = SqlUtility.ExecuteReader(command, false, false); var result = EntityFlexible.ConvertFromSqlResult <SqlSysIndexColumn>(nameof(SqlSysIndexColumn), sqlResults.First(), SqlSysIndexColumn.Factory); result.ForEach((item) => { { var obj = this.AllObjectsById.GetValueOrDefault(item.object_id); if ((object)obj != null) { var index = obj.GetIndexes().Where(_ => _.index_id == item.index_id).FirstOrDefault(); if ((object)index != null) { index.IndexColumns.Add(item); } } } }); return(result); } }
/// <summary> /// Read the databases from the server; /// </summary> /// <returns>the databases</returns> public List <SqlSysDatabase> ReadDatabases() { var sqlTransConnection = this.EnsureOpenTransConnection(); try { using (var command = sqlTransConnection.SqlCommand(System.Data.CommandType.Text, SqlSysDatabase.SELECTAllStatement)) { var sqlResults = SqlUtility.ExecuteReader(command, false, false); var result = EntityFlexible.ConvertFromSqlResult <SqlSysDatabase>(nameof(SqlSysDatabase), sqlResults.First(), SqlSysDatabase.Factory); result.ForEach((item) => { this.DatabaseById[item.database_id] = item; }); return(result); } } catch { } try { 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); result.ForEach((item) => { this.DatabaseById[item.database_id] = item; }); return(result); } } catch { } return(new List <SqlSysDatabase>()); }