Skip to content

Commit f065526

Browse files
authored
Merge pull request #107 from peetw/feature/ms-sql-net-standard
Target .NET Standard with MsSql dialect
2 parents e42b0a4 + a1c1456 commit f065526

34 files changed

+182
-2016
lines changed

NHibernate.Spatial.MsSql/Dialect/MsSql2008FunctionRegistration.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,15 +382,23 @@ public virtual SqlString GetSpatialRelationString(object geometry, SpatialRelati
382382
return GetSpatialRelationString(anotherGeometry, SpatialRelation.Covers, geometry, criterion);
383383

384384
default:
385-
return new SqlStringBuilder(8)
386-
.AddObject(geometry)
387-
.Add(".ST")
388-
.Add(relation.ToString())
389-
.Add("(")
390-
.AddObject(anotherGeometry)
391-
.Add(")")
392-
.Add(criterion ? " = 1" : "")
393-
.ToSqlString();
385+
// NOTE: Cast is only required if "geometry" is passed in as a parameter
386+
// directly, rather than as a column name. This is because parameter
387+
// will be passed as binary and SQL Server can't call methods on
388+
// binary data.
389+
return new SqlStringBuilder()
390+
.Add("CAST(")
391+
.AddObject(geometry)
392+
.Add(" AS ")
393+
.Add(sqlTypeName)
394+
.Add(")")
395+
.Add(".ST")
396+
.Add(relation.ToString())
397+
.Add("(")
398+
.AddObject(anotherGeometry)
399+
.Add(")")
400+
.Add(criterion ? " = 1" : "")
401+
.ToSqlString();
394402
}
395403
}
396404

NHibernate.Spatial.MsSql/Dialect/MsSql2008GeographyDialect.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace NHibernate.Spatial.Dialect
2323
public class MsSql2008GeographyDialect : MsSql2008SpatialDialect
2424
{
2525

26-
private static readonly IType geometryType = new CustomType(typeof(MsSql2008GeographyType), null);
26+
private static readonly IType geometryType = new CustomType(typeof(MsSqlGeographyType), null);
2727

2828
public MsSql2008GeographyDialect()
2929
: base("geography", "NHSP_GEOGRAPHY_COLUMNS", geometryType)
@@ -36,7 +36,7 @@ public MsSql2008GeographyDialect()
3636
/// <returns></returns>
3737
public override IGeometryUserType CreateGeometryUserType()
3838
{
39-
return new MsSql2008GeographyType();
39+
return new MsSqlGeographyType();
4040
}
4141
}
4242
}

NHibernate.Spatial.MsSql/Dialect/MsSql2008GeometryDialect.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ namespace NHibernate.Spatial.Dialect
2323
public class MsSql2008GeometryDialect : MsSql2008SpatialDialect
2424
{
2525

26-
private static readonly IType geometryType = new CustomType(typeof(MsSql2008GeometryType), null);
26+
private static readonly IType geometryType = new CustomType(typeof(MsSqlGeometryType), null);
2727

2828
public MsSql2008GeometryDialect()
29-
: base("geometry", "NHSP_GEOMETRY_COLUMNS",geometryType)
29+
: base("geometry", "NHSP_GEOMETRY_COLUMNS", geometryType)
3030
{
3131
}
3232

@@ -36,7 +36,7 @@ public MsSql2008GeometryDialect()
3636
/// <returns></returns>
3737
public override IGeometryUserType CreateGeometryUserType()
3838
{
39-
return new MsSql2008GeometryType();
39+
return new MsSqlGeometryType();
4040
}
4141
}
4242
}

NHibernate.Spatial.MsSql/Dialect/MsSql2012GeographyDialect.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace NHibernate.Spatial.Dialect
2222
{
2323
public class MsSql2012GeographyDialect : MsSql2012SpatialDialect
2424
{
25-
private static readonly IType geometryType = new CustomType(typeof(MsSql2008GeographyType), null);
25+
private static readonly IType geometryType = new CustomType(typeof(MsSqlGeographyType), null);
2626

2727
public MsSql2012GeographyDialect()
2828
: base("geography", "NHSP_GEOGRAPHY_COLUMNS", geometryType)
@@ -34,7 +34,7 @@ public MsSql2012GeographyDialect()
3434
/// <returns></returns>
3535
public override IGeometryUserType CreateGeometryUserType()
3636
{
37-
return new MsSql2008GeographyType();
37+
return new MsSqlGeographyType();
3838
}
3939
}
4040
}

NHibernate.Spatial.MsSql/Dialect/MsSql2012GeometryDialect.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace NHibernate.Spatial.Dialect
2222
{
2323
public class MsSql2012GeometryDialect : MsSql2012SpatialDialect
2424
{
25-
private static readonly IType geometryType = new CustomType(typeof(MsSql2008GeometryType), null);
25+
private static readonly IType geometryType = new CustomType(typeof(MsSqlGeometryType), null);
2626

2727
public MsSql2012GeometryDialect()
2828
: base("geometry", "NHSP_GEOMETRY_COLUMNS", geometryType)
@@ -34,7 +34,7 @@ public MsSql2012GeometryDialect()
3434
/// <returns></returns>
3535
public override IGeometryUserType CreateGeometryUserType()
3636
{
37-
return new MsSql2008GeometryType();
37+
return new MsSqlGeometryType();
3838
}
3939
}
4040
}

NHibernate.Spatial.MsSql/NHibernate.Spatial.MsSql.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="../NHibernate.Spatial.props" />
33

44
<PropertyGroup>
5-
<TargetFramework>net461</TargetFramework>
5+
<TargetFramework>netstandard2.0</TargetFramework>
66
<RootNamespace>NHibernate.Spatial</RootNamespace>
77
</PropertyGroup>
88

@@ -12,7 +12,8 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.SqlServer.Types" Version="11.0.2" />
15+
<PackageReference Include="NetTopologySuite.IO.SqlServerBytes" Version="1.15.1" />
16+
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
1617
</ItemGroup>
1718

1819
<ItemGroup>

NHibernate.Spatial.MsSql/Type/MsSql2008GeographyReader.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

NHibernate.Spatial.MsSql/Type/MsSql2008GeographyType.cs

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)