QueryFilter in ArcGIS PRO SDK

970
5
03-09-2022 04:36 AM
by Anonymous User
Not applicable

Hi,

I'm connecting to FGDB and then firing the queryFilter in ArcGIS Pro SDK, which is where I'm having trouble because it's not going inside the while loop.

queryFilter which i'm using is:

-----------------------------------------------------------------------------------

QueryFilter routesQueryFilter = new QueryFilter();
routesQueryFilter.WhereClause = templateDesignerProperties.PipelineRouteID + "='" + selectedLineId + "'";

----------------------------------------------------------------------------

and the rowCursor:

----------------------------------------------------------------------------

QueuedTask.Run(() =>
{

using (RowCursor rowCursor = featureClassOpenedAsTableRoute.Search(queryFilter, false))
{
while (rowCursor.MoveNext())
{
//code here

}
}
});

-------------------------------------------------------------------------------------------

Could anyone please tell me the issue that is preventing  it from entering the while loop?

Thanks in advance!!

0 Kudos
5 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

The answer could be: no records matching to your query filter. You can check it by adding code line before calling Search method.

 

var count = featureClassOpenedAsTableRoute.GetCount(queryFilter);

Count must be equal 0 in your case.

0 Kudos
by Anonymous User
Not applicable

Hi @GKmieliauskas  Yes you are right, but when I'm connecting it to SDE Database its pretty much happening but the problem is when I connect to FGDB , I also checked the whereClause the, value is coming but why the count is still 0 ??

0 Kudos
GKmieliauskas
Esri Regular Contributor

Stop debugger before calling Search.

Copy routesQueryFilter.WhereClause value from Watch window to clipboard. Finish your tool work.

Open the featureClassOpenedAsTableRoute table in ArcGIS Pro table view and try Select by Attribute with whereclause string from clipboard. Check before that SQL query type is on.

If result still 0, try create query with query builder and check for differences

by Anonymous User
Not applicable

Thanks, the same way I debugged the code and then tried using the same whereClause in my ArcGIS Pro application, where I discovered a mistake in the query because the application was not retrieving any records. I fixed it, and now its working as expected 🙂

 

Thanks again!!

0 Kudos
StephenRhea_NV5
Occasional Contributor

What data type is templateDesignerProperties.PipelineRouteID? If it's a number, it may be thrown off by the quotes around selectedLineId. If it's a GUID, you'll need to add braces around it by calling

selectedLineId.ToString("B", CultureInfo.CurrentCulture).ToUpper(CultureInfo.CurrentCulture);
0 Kudos