public ColumnResource(ServerContext context, string dbName, string schemaName, string tableName, string columnName, IUrlHelper urlHelper) { this._context = context; // Get database by name this._context.SmoServer.Databases.Refresh(); SMO.Database smoDb = this._context.SmoServer.Databases[dbName]; if (smoDb == null) { throw new SMO.SmoException(String.Format("Database '{0}' not found.", dbName)); } // Get table by name smoDb.Tables.Refresh(); SMO.Table smoTable = smoDb.Tables[tableName, schemaName]; if (smoTable == null) { throw new SMO.SmoException(String.Format("Table '{0}' not found in Schema '{1}' in Database '{1}'.", tableName, schemaName, dbName)); } // Get column by name smoTable.Columns.Refresh(); this._smoColumn = smoTable.Columns[columnName]; if (this._smoColumn == null) { throw new SMO.SmoException(String.Format("Column {0} not found in Table {1} not found in Database {2}.", columnName, tableName, dbName)); } this._parent = this._smoColumn.Parent; this._smoTable = (SMO.Table) this._parent; // TODO: handle other types of parents (only handling Table for now) this.UpdateLinks(urlHelper); }
public static Boolean IsView(this Microsoft.SqlServer.Management.Smo.SqlSmoObject b) { Boolean bIsVIew = false; if (b is View) { bIsVIew = true; } return(bIsVIew); }