Since we are not going to see a solution from the Silverlight team to easily query attributes in the application builder, I have finally built a solution to do so. This is a hack-in from the back into the configuration files and it is for me not the correct way to do it. But it is a solutionProvided is a Visual Studio 2010 solution. XAP file not included. It is based on the query example but much more user friendly. Feel free to use it. It is provided as is and I am NOT providing any supportPLEASE NOTE: The Viewer API does not contain options to obtain the fields with their settings as defined by the Application Builder. This tool assumes that definitions for the framework won???t change. If it does it could potentially break the functionality of the attribute query toolThe add-in will fail and not work within Application Builder. The configuration xml is different for the application builder than for a deployed site. Add the add-in and test it on a deployed site.Note the following:??? The tool uses the currently selected layer (only feature layers can be queried)??? A new query results layer will be added for every type of feature (point, polyline and polygon). These will be replaced with new result sets for each query performed ??? No configuration is required as all the fields, as defined in the application builder, are used (the visibility settings and field alias names are used)??? Operations are transformed to the appropriate format for the type of field it applies to, e.g. for a string ???=??? will be replaced with ???LIKE???, etc.??? Values for string fields don???t need to be in quotes.??? Wildcards don???t need to be used, e.g. if field value is ???METRO??? and operator ???=??? is used only value of ???METRO??? will match but for the operator ???LIKE??? the value of ???MET??? will match ???METRO???.??? Wildcards are not used for the ???IN??? operation??? The values are case sensitive, e.g. if field value is ???METRO??? the search term ???metro??? will not match. I am still working on solving this??? Comma delimited values can be used for both string and numeric values, e.g. field ???OBJECTID??? values of ???1,2,3??? will match where OBJECTID=1, OBJECTID=2 AND OBJECTID=3It has not been tested with dates, etc. Have tested strings and numeric values. UPDATE: replace code with snippet below (date bit added). It is not in download The were clause constructor is as follows:Format for queryString is: {Field} {Operation} {Value}
if (fType == Field.FieldType.String)
{
queryString = "{0} {1} '%{2}%'";
if (operation == "=") queryString = "{0} LIKE '{2}'";
if (operation == "IN") queryString = "{0} IN ('{2}')";
if (operation == "NOT") queryString = "NOT {0} LIKE '{2}'";
if (whereValue.Contains(",")) whereValue = whereValue.Replace(",", "','");
}
else if (fType == Field.FieldType.Date)
{
DateTime dt = new DateTime();
bool b = DateTime.TryParse(whereValue, out dt);
if (b == true)
{
whereValue = dt.ToString("MM/dd/yyyy");
queryString = "{0} {1} '{2}'";
if (operation == "LIKE") queryString = "{0} = '{2}'";
if (operation == "IN") queryString = "{0} = '{2}'";
if (operation == "NOT") queryString = "{0} <> '{2}'";
}
else return;
}
else
{
queryString = "{0} {1} {2}";
if (operation == "IN") queryString = "{0} IN ({2})";
if (operation == "NOT") queryString = "{0} <> {2}";
}
if (operation == "IS NULL") queryString = "{0} IS NULL";
if (operation == "NOT IS NULL") queryString = "NOT {0} IS NULL";
Hope it helps