Closed tiksn closed 2 years ago
/cc @roji
@tiksn for the null case, I couldn't reproduce your problem - inserting a parameterized null NetTopologySuite Polygon seems to work fine in the code sample below. Can you please double-check your code, and if the problem persists, submit a runnable repro (or tweak the sample below) so that it shows the problem?
However, for the empty polygon case I can confirm I see the bug, this seems to be tracked by https://github.com/NetTopologySuite/NetTopologySuite.IO.SqlServerBytes/issues/14 on the NetTopologySuite (and it indeed seems to be similar/identical to https://github.com/NetTopologySuite/NetTopologySuite.IO.PostGis/issues/14 on the PostgreSQL side).
@roji thanks for reply and code sample
Your code sample works on my side as well.
Executed DbCommand (37ms) [Parameters=[@p0='e24f28ae-3a40-45bc-8679-d5767972b164', @p1='' (DbType = Object), @p2='' (DbType = Object), @p3='foo' (Size = 4000), @p4='False', @p5='0'], CommandType='Text', CommandTimeout='30']
SET NOCOUNT ON;
INSERT INTO [Bookmarks] ([ID], [Boundaries], [Center], [Name], [Permanent], [Zoom])
VALUES (@p0, @p1, @p2, @p3, @p4, @p5);
Even from log we can see that value is empty.
Turns out that SRID = 4326
was missing for Center. Because my recent changes were only about Boundaries that confused me.
Sorry for misleading bug report and thanks for quick and detailed help.
I have same issue as here but with SQL Server.
I am passing
Polygon
property asNULL
but in query I see this@p2='0x00000000010C9D94826842394940000000D05D863E40'
I have a
Bookmark
entity withBoundaries
property of typePolygon
. In some cases, it will not be provided so should be null.Creating and saving as
after calling
this is getting logged on console
with and exception
However following query work fine (when queried manually directly against SQL Server Express
Why is EF Core passing
@p2='0x00000000010C9D94826842394940000000D05D863E40'
instead ofNULL
?EF Core version: 5.0.5 Database provider: Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite 5.0.5 Target framework: .NET 5.0 Operating system: Windows 10 IDE: Rider 2021.1
P.S. I tried to pass empty Polygon but that results in another exception complaining that
Ring has fewer than 4 points, so orientation cannot be determined
.