mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-18 22:31:08 +08:00
78ed4b2077
One of several moves to make this something we can dev on all platforms and build on Actions for v3 onwards.
74 lines
2.6 KiB
C#
74 lines
2.6 KiB
C#
#if ENTITY_FRAMEWORK
|
|
using System;
|
|
using System.Data.Entity.Spatial;
|
|
using System.Linq;
|
|
using Xunit;
|
|
|
|
namespace Dapper.Tests.Providers
|
|
{
|
|
public sealed class SystemSqlClientEntityFrameworkTests : EntityFrameworkTests<SystemSqlClientProvider> { }
|
|
#if MSSQLCLIENT
|
|
public sealed class MicrosoftSqlClientEntityFrameworkTests : EntityFrameworkTests<MicrosoftSqlClientProvider> { }
|
|
#endif
|
|
|
|
[Collection("TypeHandlerTests")]
|
|
public abstract class EntityFrameworkTests<TProvider> : TestBase<TProvider> where TProvider : DatabaseProvider
|
|
{
|
|
public EntityFrameworkTests()
|
|
{
|
|
EntityFramework.Handlers.Register();
|
|
}
|
|
|
|
[Fact]
|
|
public void Issue570_DbGeo_HasValues()
|
|
{
|
|
SkipIfMsDataClient();
|
|
|
|
EntityFramework.Handlers.Register();
|
|
const string redmond = "POINT (-122.1215 47.6740)";
|
|
DbGeography point = DbGeography.PointFromText(redmond, DbGeography.DefaultCoordinateSystemId);
|
|
DbGeography orig = point.Buffer(20);
|
|
|
|
var fromDb = connection.QuerySingle<DbGeography>("declare @geos table(geo geography); insert @geos(geo) values(@val); select * from @geos",
|
|
new { val = orig });
|
|
|
|
Assert.NotNull(fromDb.Area);
|
|
Assert.Equal(orig.Area, fromDb.Area);
|
|
}
|
|
|
|
[Fact]
|
|
public void Issue22_ExecuteScalar_EntityFramework()
|
|
{
|
|
SkipIfMsDataClient();
|
|
|
|
var geo = DbGeography.LineFromText("LINESTRING(-122.360 47.656, -122.343 47.656 )", 4326);
|
|
var geo2 = connection.ExecuteScalar<DbGeography>("select @geo", new { geo });
|
|
Assert.NotNull(geo2);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestGeometryParsingRetainsSrid()
|
|
{
|
|
const int srid = 27700;
|
|
var s = $@"DECLARE @EdinburghPoint GEOMETRY = geometry::STPointFromText('POINT(258647 665289)', {srid});
|
|
SELECT @EdinburghPoint";
|
|
var edinPoint = connection.Query<DbGeometry>(s).Single();
|
|
Assert.NotNull(edinPoint);
|
|
Assert.Equal(srid, edinPoint.CoordinateSystemId);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestGeographyParsingRetainsSrid()
|
|
{
|
|
const int srid = 4324;
|
|
var s = $@"DECLARE @EdinburghPoint GEOGRAPHY = geography::STPointFromText('POINT(-3.19 55.95)', {srid});
|
|
SELECT @EdinburghPoint";
|
|
var edinPoint = connection.Query<DbGeography>(s).Single();
|
|
Assert.NotNull(edinPoint);
|
|
Assert.Equal(srid, edinPoint.CoordinateSystemId);
|
|
}
|
|
|
|
}
|
|
}
|
|
#endif
|