I am adding a FeatureLayer to the current map. The FL is backed by table in a SQL Server database. This is how I add the FL:
var connProps = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
{
Instance = "my remote instance",
Database = "dbname",
User = "****",
Password = "****",
AuthenticationMode = AuthenticationMode.DBMS,
};
var gdb = new Geodatabase(connProps);
CIMSqlQueryDataConnection connection = new CIMSqlQueryDataConnection()
{
WorkspaceConnectionString = gdb.GetConnectionString(),
GeometryType = esriGeometryType.esriGeometryPolygon,
OIDFields = "OBJECTID",
Srid = "32632",
SqlQuery = "select * from [dbname].[fb_gdb].[TRAININGAREA]",
Dataset = "TrainingAreas",
DatasetType = esriDatasetType.esriDTFeatureClass
};
var layerParams = new LayerCreationParams(connection )
{
Name = Constants.LayerTrainingAreasName
};
var layer = LayerFactory.Instance.CreateLayer<FeatureLayer>(layerParams, MapView.Active.Map);
The layer contains polygons and I added a renderer with a pink outline. During panning/zooming the features are not drawn well - sometimes completely missing, sometimes a chunk of the outline is missing:

If I add the same layer via Pro's Catalog -> Databases -> Add connection, and then drag and drop the layer into the map, it behaves correctly.
Any ideas?
I have tried to add the connection to the Catalog via code to see if that helps but was unable to figure out how to do that
Project.Current.AddItem( how do I make an IProjectItem out of the GDB or the connection?? )