/// <summary> /// Creates SQL to create auxiliary database objects. /// </summary> /// <param name="dialect">The dialect.</param> /// <param name="mapping">The mapping.</param> /// <param name="defaultCatalog">The default catalog.</param> /// <param name="defaultSchema">The default schema.</param> /// <returns></returns> public override string SqlCreateString(NHibernate.Dialect.Dialect dialect, IMapping mapping, string defaultCatalog, string defaultSchema) { ISpatialDialect spatialDialect = (ISpatialDialect)dialect; StringBuilder builder = new StringBuilder(); // Create general objects builder.Append(spatialDialect.GetSpatialCreateString(defaultSchema)); // Create objects per column VisitGeometryColumns(delegate(Table table, Column column) { // Ugly trick: We use Comparator property to get the column instance of IGeometryUserType. // (Comparator is mainly used in IVersionType comparisons) // Maybe it will require to implement IComparer in IGeometryUserType, just to comply. // // It would be nicer if CustomType made UserType property public (today is protected). IGeometryUserType geometryType = (IGeometryUserType)((CustomType)column.Value.Type).Comparator; // The previous trick allows to get geometry type properties, such as SRID. int srid = geometryType.SRID; string subtype = geometryType.Subtype; builder.Append(spatialDialect.GetSpatialCreateString(defaultSchema, table.Name, column.Name, srid, subtype)); }); return(builder.ToString()); }
/// <summary> /// Creates SQL to create auxiliary database objects. /// </summary> /// <param name="dialect">The dialect.</param> /// <param name="mapping">The mapping.</param> /// <param name="defaultCatalog">The default catalog.</param> /// <param name="defaultSchema">The default schema.</param> /// <returns></returns> public override string SqlCreateString(NHibernate.Dialect.Dialect dialect, IMapping mapping, string defaultCatalog, string defaultSchema) { ISpatialDialect spatialDialect = (ISpatialDialect)dialect; StringBuilder builder = new StringBuilder(); // Create general objects builder.Append(spatialDialect.GetSpatialCreateString(defaultSchema)); // Create objects per column VisitGeometryColumns(delegate(Table table, Column column) { IGeometryUserType geometryType = (IGeometryUserType)((CustomType)column.Value.Type).UserType; int srid = geometryType.SRID; string subtype = geometryType.Subtype; int dimension = geometryType.Dimension; builder.Append(spatialDialect.GetSpatialCreateString(defaultSchema, table.Name, column.Name, srid, subtype, dimension)); }); return(builder.ToString()); }
/// <summary> /// Creates SQL to create auxiliary database objects. /// </summary> /// <param name="dialect">The dialect.</param> /// <param name="mapping">The mapping.</param> /// <param name="defaultCatalog">The default catalog.</param> /// <param name="defaultSchema">The default schema.</param> /// <returns></returns> public override string SqlCreateString(NHibernate.Dialect.Dialect dialect, IMapping mapping, string defaultCatalog, string defaultSchema) { ISpatialDialect spatialDialect = (ISpatialDialect)dialect; StringBuilder builder = new StringBuilder(); // Create general objects builder.Append(spatialDialect.GetSpatialCreateString(defaultSchema)); // Create objects per column VisitGeometryColumns((tbl, col) => ColumnVisitorSQLCreate(tbl, col, builder, defaultSchema, spatialDialect)); return(builder.ToString()); }
private void ColumnVisitorSQLCreate(Table table, Column column, StringBuilder builder, string defaultSchema, ISpatialDialect spatialDialect) { IGeometryUserType geometryType = (IGeometryUserType)((CustomType)column.Value.Type).UserType; int srid = geometryType.SRID; var key = table.Name + "." + column.Name; if (SridMap.ContainsKey(key) && SridMap[key] > 0) { srid = SridMap[key]; } string subtype = geometryType.Subtype; int dimension = geometryType.Dimension; builder.Append(spatialDialect.GetSpatialCreateString(defaultSchema, table.Name, column.Name, srid, subtype, dimension, column.IsNullable)); }
public string GetSpatialCreateString(string schema) { return(worker.GetSpatialCreateString(schema)); }
private void ColumnVisitorSQLCreate(Table table, Column column, StringBuilder builder, string defaultSchema, ISpatialDialect spatialDialect) { IGeometryUserType geometryType = (IGeometryUserType)((CustomType)column.Value.Type).UserType; int srid = geometryType.SRID; var key = table.Name + "." + column.Name; if (SridMap.ContainsKey(key) && SridMap[key] > 0) { srid = SridMap[key]; } string subtype = geometryType.Subtype; int dimension = geometryType.Dimension; builder.Append(spatialDialect.GetSpatialCreateString(defaultSchema, table.Name, column.Name, srid, subtype, dimension, column.IsNullable)); }