CIMSqlQueryDataConnection Couting rows

252
2
08-30-2022 01:05 AM
Daniel4
New Contributor II

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);

}

 

 

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor
0 Kudos
Daniel4
New Contributor II

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();

0 Kudos