Select to view content in your preferred language

Query Syntax

918
4
04-22-2011 05:25 AM
JayKappy
Frequent Contributor
I know this might not be ArcGIS API question and rather more a general programming question but I have been all over silverlight forums and keep getting references to LINQ query structure...

Where Equal to is represented with ==
Greater than equal to with >=
etc

But this is more in the body of the ESRI.ArcGIS.Client.Tasks.Query and they dont seem to work...
PrecinctValue2 is a variable set to result of another query...its set to a specific attribute value from that found record...there will be only 1 record returned..

This works:
query.Where = String.Format("ELEM_TEXT LIKE '%{0}%'", PrecinctValue2.Trim)

But I need EQUAL to the value in the string....I have been trying == instead of the LIKE..
This DOES NOT work...Any quick thoughts?

query.Where = String.Format("ELEM_TEXT == '%{0}%'", PrecinctValue2.Trim)

Any quick thoughts....no worries either way....just thought I would give this a try....
0 Kudos
4 Replies
TerryGiles
Frequent Contributor
Jay,

Just use a single equal sign in the where clause.

query.Where = "ELEM_TEXT = '" + PrecinctValue2.Trim + "'";


note that are there are single quote marks around precinctvalue2 since this is a string field.  Numeric (and date types I believe) do not need these.

TG
0 Kudos
JayKappy
Frequent Contributor
Thank you terry....very apprecited...sort fo feel stupid....so much more simple syntax than teh example I as using....

Can I assume that you can simply use >=, <=, >, <   symbology as well to create Greater Than Equal to, Less THan Equal to, Greater THan, Less Than...making sure the variable is numeric...

THanks Again...very appreciated
0 Kudos
TerryGiles
Frequent Contributor
yep just use >=, <, etc.. in the string you set for the Where property.  Depending on the underlying data source you can also use

between <number> and <number> or between '<date>' and '<date>'.  Dates are enclosed in single quote marks like a string.

Terry
0 Kudos
JayKappy
Frequent Contributor
THanks again...have a great weekend....
0 Kudos