0

I am trying to construct a linestring using SqlGeometryBuilder.

SqlGeometry point = line.STPointN(x)
gb.BeginFigure((double)point.X, (double)point.Y, (double?)point.Z, (double?)point.M);

The .Z and .M properties of the SqlGeometry return as type SqlDouble, so I tried casting them both to double?. However, casting these properties seems to call .Value on the property which will throw a null exception rather than returning null, breaking my code.

Is there a way to cast which doesn't invoke .Value for the SqlGeometry Z and M values?

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
Maximus
  • 1,244
  • 10
  • 12
  • Please, do not include information about a language used in a question title unless it wouldn't make sense without it. Tags serve this purpose. – Ondrej Janacek Feb 28 '14 at 07:29

1 Answers1

3

Can this help?

SqlGeometry point = line.STPointN(x)
gb.BeginFigure((double)point.X, (double)point.Y, point.HasZ ? (double?)point.Z : (double?)null, point.HasM ? (double?)point.M : (double?)null );
Sriram Sakthivel
  • 72,067
  • 7
  • 111
  • 189