I have created a CIMSqlQueryDataConnection object to retrive data from an oracle database, and displaying in AGP using FeatureLayer. Some of the queries dont return any data, but still showing a layer. Is there a method I can use, to count the number of rows from the queries, and not showing them, that return zero rows?
I am using this code:
using (Database oracleDatabase = new Database(conProperties))
{
Map map = MapView.Active.Map;
CIMSqlQueryDataConnection sqldc = new CIMSqlQueryDataConnection()
{
WorkspaceConnectionString = oracleDatabase.GetConnectionString(),
GeometryType = this.geomType,
OIDFields = "OBJECTID",
Srid = "25832",
SqlQuery = "SELECT * from" + this.tableName,
Dataset = this.tableName
};
FeatureLayer flyr = (FeatureLayer)LayerFactory.Instance.CreateLayer(sqldc, map, layerName: tableName);
}
Hi,
From oracleDatabase call OpenTable and then from table you can get count of rows.
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic6928.html
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic17394.html
Hi, thanks
I tried using the documentation with the CIMsqlQueryDataConnection, but I didn't managed.
Insted I change the connection to be used in the QueryDescription, and it worked:
QueryDescription queryDescription = oracleDatabase.GetQueryDescription(SQLquery, this.tableName);
queryDescription.SetObjectIDFields("OBJECTID");
queryDescription.SetShapeType(geomType);
SpatialReference spatialReference = MapView.Active.Map.SpatialReference;
Table table = oracleDatabase.OpenTable(queryDescription);
int count = table.GetCount();