Save / update features in MSSQL datatbase from features reading from an Esri ".gdb" database

Hi,
I Export features from my MS SQL database ( tables containing a geometry column ) to a Esri “.gdb” database using Aspose.

This export is send to others to evaluate and I get the data back as a Esri “*.gdb” file , with changed geometries / features.

I have trouble saving the feature.geometry back to the SQL Server geometry field using EF core .

EF core entity geom field is of type Geometry and using NetTopologySuite .
Aspose.Gis has type IGeometry does not convert to NetTopologySuite.Geometries.Geometry type.

Please help.

Regards,
Mehmet

Hi, @mcanavar

You have the opportunity to make a small example of how you use EF?

Thanks

Hi @Evgeniy.Timofeev,

Found a workaround for now, but perhaps I have missed some thing

Part of the c# code below,

  //NTS GeometryService WKBReader 
  WKBReader wkbReader = new WKBReader(new NetTopologySuite.NtsGeometryServices());

 foreach (var feature in layer)
 {
  var ef_entity = new ef_entity();
  ef_entity.OBJECTID = feature.GetValue<long?>("OBJECTID");

  // from Asspose.Gis.IGeometry  to NetTopologySuite.Geometries.Geometry
  ef_entity.geom = wkbReader.Read(feature.Geometry.AsBinary());

  //add to EF
  context.ef_entites.Add(ef_entity);

}
//commit EF
context.SaveChanges();

//---

This solved my problem , but perhaps there is a beter solution to do this with only Aspose.Gis.

Regards,
Mehmet

Hi, @mcanavar

I see no other way. I like your solution.

1 Like