Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak SpatialDimension -> GeometricDimension #16845

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ public static bool CanSetSrid(
/// The same builder instance if the configuration was applied,
/// <c>null</c> otherwise.
/// </returns>
public static IConventionPropertyBuilder HasSpatialDimension(
public static IConventionPropertyBuilder HasGeometricDimension(
[NotNull] this IConventionPropertyBuilder propertyBuilder,
[CanBeNull] string dimension,
bool fromDataAnnotation = false)
{
if (propertyBuilder.CanSetSpatialDimension(dimension, fromDataAnnotation))
if (propertyBuilder.CanSetGeometricDimension(dimension, fromDataAnnotation))
{
propertyBuilder.Metadata.SetSpatialDimension(dimension, fromDataAnnotation);
propertyBuilder.Metadata.SetGeometricDimension(dimension, fromDataAnnotation);

return propertyBuilder;
}
Expand All @@ -114,7 +114,7 @@ public static IConventionPropertyBuilder HasSpatialDimension(
/// <param name="dimension"> The dimension. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <returns> <c>true</c> if the given value can be set as the dimension for the column. </returns>
public static bool CanSetSpatialDimension(
public static bool CanSetGeometricDimension(
[NotNull] this IConventionPropertyBuilder propertyBuilder,
[CanBeNull] string dimension,
bool fromDataAnnotation = false)
Expand Down Expand Up @@ -172,11 +172,11 @@ public static IConventionPropertyBuilder ForSqliteHasSrid(
/// The same builder instance if the configuration was applied,
/// <c>null</c> otherwise.
/// </returns>
[Obsolete("Use HasSpatialDimension")]
[Obsolete("Use HasGeometricDimension")]
public static IConventionPropertyBuilder ForSqliteHasDimension(
[NotNull] this IConventionPropertyBuilder propertyBuilder,
[CanBeNull] string dimension,
bool fromDataAnnotation = false)
=> propertyBuilder.HasSpatialDimension(dimension, fromDataAnnotation);
=> propertyBuilder.HasGeometricDimension(dimension, fromDataAnnotation);
}
}
8 changes: 4 additions & 4 deletions src/EFCore.Sqlite.Core/Extensions/SqlitePropertyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public static void SetSrid([NotNull] this IConventionProperty property, int? val
/// </summary>
/// <param name="property"> The property. </param>
/// <returns> The dimension to use when creating a column for this property. </returns>
public static string GetSpatialDimension([NotNull] this IProperty property)
public static string GetGeometricDimension([NotNull] this IProperty property)
=> (string)property[SqliteAnnotationNames.Dimension];

/// <summary>
/// Sets the dimension to use when creating a column for this property.
/// </summary>
/// <param name="property"> The property. </param>
/// <param name="value"> The dimension. </param>
public static void SetSpatialDimension([NotNull] this IMutableProperty property, [CanBeNull] string value)
public static void SetGeometricDimension([NotNull] this IMutableProperty property, [CanBeNull] string value)
=> property.SetOrRemoveAnnotation(SqliteAnnotationNames.Dimension, value);

/// <summary>
Expand All @@ -68,7 +68,7 @@ public static void SetSpatialDimension([NotNull] this IMutableProperty property,
/// <param name="property"> The property. </param>
/// <param name="value"> The dimension. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
public static void SetSpatialDimension(
public static void SetGeometricDimension(
[NotNull] this IConventionProperty property, [CanBeNull] string value, bool fromDataAnnotation = false)
=> property.SetOrRemoveAnnotation(SqliteAnnotationNames.Dimension, value, fromDataAnnotation);

Expand All @@ -77,7 +77,7 @@ public static void SetSpatialDimension(
/// </summary>
/// <param name="property"> The property. </param>
/// <returns> The <see cref="ConfigurationSource" /> for the column dimension. </returns>
public static ConfigurationSource? GetSpatialDimensionConfigurationSource([NotNull] this IConventionProperty property)
public static ConfigurationSource? GetGeometricDimensionConfigurationSource([NotNull] this IConventionProperty property)
=> property.FindAnnotation(SqliteAnnotationNames.Dimension)?.GetConfigurationSource();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public override IEnumerable<IAnnotation> For(IProperty property)
yield return new Annotation(SqliteAnnotationNames.Srid, srid);
}

var dimension = property.GetSpatialDimension();
var dimension = property.GetGeometricDimension();
if (dimension != null)
{
yield return new Annotation(SqliteAnnotationNames.Dimension, dimension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class SqliteNetTopologySuitePropertyBuilderExtensions
/// <param name="propertyBuilder"> The builder for the property being configured. </param>
/// <param name="ordinates"> The dimension ordinates. </param>
/// <returns> The same builder instance so that multiple calls can be chained. </returns>
public static PropertyBuilder HasSpatialDimension(
public static PropertyBuilder HasGeometricDimension(
[NotNull] this PropertyBuilder propertyBuilder,
Ordinates ordinates)
{
Expand All @@ -37,7 +37,7 @@ public static PropertyBuilder HasSpatialDimension(
dimension += "M";
}

propertyBuilder.Metadata.SetSpatialDimension(dimension);
propertyBuilder.Metadata.SetGeometricDimension(dimension);

return propertyBuilder;
}
Expand All @@ -48,33 +48,33 @@ public static PropertyBuilder HasSpatialDimension(
/// <param name="propertyBuilder"> The builder for the property being configured. </param>
/// <param name="ordinates"> The dimension ordinates. </param>
/// <returns> The same builder instance so that multiple calls can be chained. </returns>
public static PropertyBuilder<TProperty> HasSpatialDimension<TProperty>(
public static PropertyBuilder<TProperty> HasGeometricDimension<TProperty>(
[NotNull] this PropertyBuilder<TProperty> propertyBuilder,
Ordinates ordinates)
=> (PropertyBuilder<TProperty>)HasSpatialDimension((PropertyBuilder)propertyBuilder, ordinates);
=> (PropertyBuilder<TProperty>)HasGeometricDimension((PropertyBuilder)propertyBuilder, ordinates);

/// <summary>
/// Configures the dimension of the column that the property maps to when targeting SQLite.
/// </summary>
/// <param name="propertyBuilder"> The builder for the property being configured. </param>
/// <param name="ordinates"> The dimension ordinates. </param>
/// <returns> The same builder instance so that multiple calls can be chained. </returns>
[Obsolete("Use HasSpatialDimension")]
[Obsolete("Use HasGeometricDimension")]
public static PropertyBuilder ForSqliteHasDimension(
[NotNull] this PropertyBuilder propertyBuilder,
Ordinates ordinates)
=> propertyBuilder.HasSpatialDimension(ordinates);
=> propertyBuilder.HasGeometricDimension(ordinates);

/// <summary>
/// Configures the dimension of the column that the property maps to when targeting SQLite.
/// </summary>
/// <param name="propertyBuilder"> The builder for the property being configured. </param>
/// <param name="ordinates"> The dimension ordinates. </param>
/// <returns> The same builder instance so that multiple calls can be chained. </returns>
[Obsolete("Use HasSpatialDimension")]
[Obsolete("Use HasGeometricDimension")]
public static PropertyBuilder<TProperty> ForSqliteHasDimension<TProperty>(
[NotNull] this PropertyBuilder<TProperty> propertyBuilder,
Ordinates ordinates)
=> propertyBuilder.HasSpatialDimension(ordinates);
=> propertyBuilder.HasGeometricDimension(ordinates);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ public void Can_set_dimension_convention(bool obsolete)
modelBuilder
.Entity(typeof(Customer))
.Property(typeof(string), "Geometry")
.HasSpatialDimension("Z");
.HasGeometricDimension("Z");
}

var property = modelBuilder
.Entity(typeof(Customer))
.Property(typeof(string), "Geometry")
.Metadata;

Assert.Equal("Z", property.GetSpatialDimension());
Assert.Equal("Z", property.GetGeometricDimension());
}

protected virtual ModelBuilder CreateConventionModelBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public void Can_get_and_set_dimension()
.Property(e => e.Geometry)
.Metadata;

Assert.Null(property.GetSpatialDimension());
Assert.Null(property.GetGeometricDimension());

property.SetSpatialDimension("Z");
property.SetGeometricDimension("Z");

Assert.Equal("Z", property.GetSpatialDimension());
Assert.Equal("Z", property.GetGeometricDimension());

property.SetSpatialDimension(null);
property.SetGeometricDimension(null);

Assert.Null(property.GetSpatialDimension());
Assert.Null(property.GetGeometricDimension());
}

private class Customer
Expand Down