Select to view content in your preferred language

Attribute request  with clause IN

757
2
04-26-2014 02:17 AM
DIALLOAbdoulaye
Emerging Contributor
Hello Every One i have a problem with a Attribute request with clause IN
In fact i have an collection of integer and i want use the attribute requeste with IN ,that dosent work
below is the code ,i use to perform the task:

  QueryTask qTask = new QueryTask("URL");
                    qTask.ExecuteCompleted += qTaskRemplirCbox_completed;
                    Query mquery = new Query();
                    mquery.OutFields.Add("*");
                    mquery.Where = "Code_Pref  IN" + listcode; //Code_Pref is the field on the layer  ,and listcode is the collection of 
                                                                               the  integer

                    qTask.ExecuteAsync(mquery);

private void qTaskRemplirCbox_completed(Object sender, QueryEventArgs e)
          {
            //The graphics from the result Task but empty beacause the task are not executed completed.
              

           }
i want to know if the request (mquery.Where = "Code_Pref  IN" + listcode) are just or if something wrong ?

thanks in advance for any Help .
0 Kudos
2 Replies
AhmedEl-Sisi
Deactivated User
Your values should be comma separated and inside Brackets for IN operator
ex: "Code_Pref IN (value1,value2,value3,..)"

It should be something like the following:

 if (listcode.Count>0)
 {
      mquery.Where = "Code_Pref IN (" + string.Join(",", listcode.Select(x => x.ToString()).ToArray()) + ")";
 }


Regards,
0 Kudos
DIALLOAbdoulaye
Emerging Contributor
thanks for the help  cc4ever
that work well .
0 Kudos