private void locateFeature(Selection sel)
{
string serviceURL;
if (GravityMain.Target == PipeQueryBuilder.AddIns.MyDatabaseService.Table.SSGRAVITYMAIN_MV)
serviceURL = "http://whatever/";
else if (GravityMain.Target == PipeQueryBuilder.AddIns.MyDatabaseService.Table.SSPRESSURIZEDMAIN_MV)
serviceURL = "http://whatever/";
else if (GravityMain.Target == PipeQueryBuilder.AddIns.MyDatabaseService.Table.SWGRAVITYMAIN_MV)
serviceURL = "http://whatever/";
else
serviceURL = "http://whatever/";
// Query task initialization.
QueryTask queryTask = new QueryTask(serviceURL);
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
queryTask.Failed += QueryTask_Failed;
// Query task parameters. Return geometry,
Query query = new Query();
query.ReturnGeometry = true;
query.OutFields.Add("*");
query.Where = constructWHERECLAUSE(sel);
queryTask.ExecuteAsync(query);
}
public string constructWHERECLAUSE(Selection sel)
{
string whereclause = string.Empty;
whereclause += "PIPEMATERIAL = " + "'" + sel.PipeMaterial + "'" + " AND WIDTH IN (" + GravityMain.conCatSizes(sel) + ")";
whereclause += " and status = 1 ";
if (sel.Owner != 0)
whereclause += " and ptable.ownership = " + "'" + sel.Owner + "'";
if (sel.SubType != 0)
whereclause += " and subtype = " + "'" + sel.SubType + "'";
if (sel.Rehab != "ALL")
whereclause += " and rehabtype = " + "'" + sel.Rehab + "'";
if (sel.SanitaryOption != SanitaryOptions.NOT_SANITARY)
if (sel.SanitaryOption == SanitaryOptions.COMBINED)
whereclause += " and ((SUBSTR(FACILITYID, 19, 1) = 'C') or (SUBSTR(FACILITYID, 21, 1) = 'C'))";
else if (sel.SanitaryOption == SanitaryOptions.SANITARY)
whereclause += " and ((SUBSTR(FACILITYID, 19, 1) = 'S') or (SUBSTR(FACILITYID, 21, 1) = 'S'))";
return whereclause;
}
Can I use QueryTask Where clause like in the code above? The above code works but it appears that it does not return all the features on the map that meets the SQL criteria. My only reasonable suspicion is that the QueryTask where clause gets confused when it sees the SUBSTR( ). I am not sure because the code runs fine with no exceptions or compile error. The only thing is that it does not return all the features that meets the SQL criteria and other times it does return all the features that matches the SQL criteria. Does anyone have any suggestion that might be helpful. I need help with this. Thanks in Advance.