0

我正在使用 Visual Studio 2019 在 .NET Core 3.1 中开发应用程序,并且在装有 Windows 10 Pro 的本地计算机上一切正常。但是部署到 Azure 后会出现这个问题:

The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 9 ("@p8"): The supplied value is not a valid instance of data type geography. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision

将 Post 添加到数据库时会发生此错误。Post 具有 type 属性,NetTopologySuite.Geometries.Point并且设置如下: location = new Point(longitude, latitude) { SRID = 4326 };经度和纬度是双倍的。

当我将位置设置为空时,不会出现错误。我尝试使用较低的精度,例如点之前的 2 位数字和之后的 6 位数字 - 这仍然会导致错误。

我使用实体框架核心。它将 db 列生成为Location (geography, null).

编辑:我正在将 lat 和 lon 字符串转换为这样的双精度:Convert.ToDouble(longitude.Replace(".", ",")). 我删除.Replace(".", ",")了它,现在它可以在 Azure 上运行,但同样的错误出现在本地环境中。我在两个数据库上都有 id 4326 的空间。

4

1 回答 1

0

最后我改变了:

Convert.ToDouble(longitude.Replace(".", ","))

Convert.ToDouble(longitude, CultureInfo.InvariantCulture)

现在它适用于本地和 Azure。

受此启发的解决方案:string to double issue, dot is removed

于 2020-06-23T14:23:34.710 回答