Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

批量插入含几何属性的实体集到postgis,报错geometry不存在 #369

Closed
laddg8 opened this issue Jul 12, 2020 · 2 comments
Closed

Comments

@laddg8
Copy link

laddg8 commented Jul 12, 2020

Demo.zip
一、错误描述:

1、将实体集合(含PostgisGeometry类型属性)批量插入Postgis空间表时,有时能成功,有时报错,不稳定。

2、查询命令也是有时成功,有时报错。

Postgis已扩展,geodata库.public架构.Navaid表,search_path="$User",public。关于Geometry列、geometry _columns视图的增删改查权限都已开启。

二、环境 :

.Net Core 3.1

Postgresql 9.6

Postgis 2.3

FreeSql 1.6.0

Npgsql 4.1.3

目前能想到的原因有两个
1、数据库关于geometry列的权限问题。
2、Npgsql.LegacyPostgis对geometry类型的映射问题。

@laddg8 laddg8 closed this as completed Jul 12, 2020
@laddg8 laddg8 reopened this Jul 12, 2020
@laddg8
Copy link
Author

laddg8 commented Jul 12, 2020

1、DBConnConfiguration.pgFreeSql.Insert(listNavaid).NoneParameter() .ExecuteAffrows();
报错: The NpgsqlDbType "Geometry" isn't present in your database.You may need to install an extension or upgrade to a newer version.
2、var listNavaidPg = DBConnConfiguration.pgFreeSql.Select() .ToList();
报错 : The field "Geom" has type 'public.geometry',which is currently unknown to Npgsql.You can retrieve it as a string by marking it as unknown,please see the FAQ.

@2881099
Copy link
Collaborator

2881099 commented Jul 12, 2020

经过测试 demo LegacyPostgis 设置 srid 会所述的错误,经过增加 NetTopologySuite 类型映射后测试正常(可以保存 srid 数据)。

目前 FreeSql.Provider.PostgreSQL v1.7.0-preview0712 版本同时保留两种 gis 类型映射,可自行选择。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants