对于MakeValid方法的单元测试,我需要它。我所能找到的就是无效文本,该文本没有转换为SqlGeography。 因此,我需要以某种方式创建无效的SqlGeograpy对象。
using System.Data.SqlTypes; //use Nuget System.Data.SqlClient
using Microsoft.SqlServer.Types; //Microsoft.SqlServer.Types.dll
...
static void MakeValidTest() {
string pointString = "POINT (-112.11436060512261 33.860383682237021)";
var sqlString = new SqlString(pointString, 4326);
var sqlGeography = SqlGeography.Parse(sqlString); // how to get invalid Sql Geography???
sqlGeography = sqlGeography.MakeValid();
Console.WriteLine(sqlGeography);
}
PS与DbGeography或SQL相似的示例也可能非常有帮助。 仅供参考:与编写SQLCLR方法有关。