3 Replies Latest reply on Sep 26, 2011 8:21 AM by hanyong



      Hi Team,


      Could you please let me know how to use "In" operator in AFElement.FindElementsByAttribute method ?


      We are using below query


      AFAttributeValueQuery[] avqs = new AFAttributeValueQuery[] { new AFAttributeValueQuery(objAFElementTemplate.AttributeTemplates[attributeName], AFSearchOperator.In, "value1,value2,value3") };


      Please assist us....







        • Re: AFElement.FindElementsByAttribute

          I think AFAttributeValueQuery.AttributeValue should be an array of values that you want to match to, instead of a string seperated by comma as you have shown in your code snippet.


          For example, if I want to find all elements that has a attribute with template "Asset Name" and value of either "High Pressure" or "Low Pressure":

          AFElementTemplate boiler = Database.ElementTemplates["Boiler"]; //get element template from AF Database
          AFAttributeTemplate an = boiler.AttributeTemplates["Asset Name"]; //get attribute template from element template
          AFAttributeValueQuery cond = new AFAttributeValueQuery(an, OSIsoft.AF.Search.AFSearchOperator.In, new string[] { "High Pressure", "Low Pressure" });
          AFAttributeValueQuery[] conds = new AFAttributeValueQuery[1];
          conds[0] = cond;
          AFNamedCollectionList<AFElement> Elements = AFElement.FindElementsByAttribute(null, "B*", conds, true, AFSortField.Name, AFSortOrder.Ascending, 1000);

          Hope this helps