internal static void UnregisterInGeometryColumns(IDbConnection conn, IDbUtility dbUtility, string schema, string tableName) { string sql = string.Format( @"DELETE FROM [{0}].[Geometry_Columns] WHERE F_Table_Catalog = @pCatalog AND F_Table_Schema = @pSchema AND F_Table_Name = @pTable ", schema); using (IDbCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(dbUtility.CreateParameter("pCatalog", conn.Database, ParameterDirection.Input)); cmd.Parameters.Add(dbUtility.CreateParameter("pSchema", schema, ParameterDirection.Input)); cmd.Parameters.Add(dbUtility.CreateParameter("pTable", tableName, ParameterDirection.Input)); ExecuteNoQuery(cmd); } }
internal static void RegisterInGeometryColumns(IDbConnection conn, IDbUtility dbUtility, string schema, string tableName, string geometryColumnName, int coordDimension, int srid, string geometryType) { string sql = string.Format( @"IF EXISTS(SELECT * FROM [{0}].[Geometry_Columns] WHERE F_Table_Catalog = @pCatalog AND F_Table_Schema = @pSchema AND F_Table_Name = @pTable AND F_Geometry_Column = @pGeomColumn) BEGIN UPDATE [{0}].Geometry_Columns SET Coord_Dimension = @pCoordDimension, SRID = @pSrid, Geometry_Type = @pGeometryType WHERE F_Table_Catalog = @pCatalog AND F_Table_Schema = @pSchema AND F_Table_Name = @pTable AND F_Geometry_Column = @pGeomColumn END ELSE BEGIN INSERT INTO [{0}].[Geometry_Columns]( F_Table_Catalog , F_Table_Schema , F_Table_Name , F_Geometry_Column , Coord_Dimension , SRID , Geometry_Type) Values( @pCatalog , @pSchema , @pTable , @pGeomColumn , @pCoordDimension , @pSrid , @pGeometryType) END" , schema); using (IDbCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(dbUtility.CreateParameter("pCatalog", conn.Database, ParameterDirection.Input)); cmd.Parameters.Add(dbUtility.CreateParameter("pSchema", schema, ParameterDirection.Input)); cmd.Parameters.Add(dbUtility.CreateParameter("pTable", tableName, ParameterDirection.Input)); cmd.Parameters.Add(dbUtility.CreateParameter("pGeomColumn", geometryColumnName, ParameterDirection.Input)); cmd.Parameters.Add(dbUtility.CreateParameter("pCoordDimension", coordDimension, ParameterDirection.Input)); cmd.Parameters.Add(dbUtility.CreateParameter("pSrid", srid, ParameterDirection.Input)); cmd.Parameters.Add(dbUtility.CreateParameter("pGeometryType", geometryType, ParameterDirection.Input)); ExecuteNoQuery(cmd); } }