Reputation: 1004
I am using entity framework 6 for crud operations including a DbGeometry property. The property holds a polygon created from WellKnownText.
DbGeometry.PolygonFromText("POLYGON((1.00 1.00, 1.00 80.00, 80.00 80.00, 80.00 1.00, 1.00 1.00))", 27700);
When saving the entity binary data is stored in the spatial database. However when retrieving WellknownValue is being populated with the WellKnownText, however the Dbgeometry.WellKnownValue.WellKnownBinary property is null
(Would post image here but not enough reputation points :( )
Surely this should of been populated from the binary in the database. I have tried setting the field by the AsBinary() method with no success.
UPDATE
Thanks John but unfortunately this is not working either. I have tried:
Property.WellKnownValue.WellKnownBinary = Property.AsBinary();
which still leaves Property.WellKnownValue.WellKnownBinary as null using the QuickWatch window
Also I have tried
byte[] byteVariable = Property.AsBinary();
This does create a 93 byte long byte array I have pasted below, however this seems very empty for what it should contain.
1,3,0,0,0,1,0,0,0,5,0,0,0,0,0,0,0,0,0,240,63,0,0,0,0,0,0,240,63,0,0,0,0,0,0,240,63,0,0,0,0,0,0,84,64,0,0,0,0,0,0,84,64,0,0,0,0,0,0,84,64,0,0,0,0,0,0,84,64,0,0,0,0,0,0,240,63,0,0,0,0,0,0,240,63,0,0,0,0,0,0,240,63,
If I then try to assign that byte array to the WellKnownBinary:
Property.WellKnownValue.WellKnownBinary = byteVariable
Property.WellKnownValue.WellKnownBinary is still shown as null using the QuickWatch window
I am seriously running out of ideas :(
Upvotes: 2
Views: 868
Reputation: 3373
I'm not entirely sure why the DbGeometry.WellKnownValue.WellKnownBinary
is NULL but it shouldn't matter, the data is stored in SQL in binary format.
You're actually almost there, except DbGeometry.AsBinary()
is a getter, not a setter.
So if you do actually need it's value, simply use DbGeometry.AsBinary()
to retrieve the value (as a Byte Array).
Upvotes: 1