The IN operator no longer requires parameters!

The IN search operator you all know. Those who don't, read this. This operator is crucial if you want to search for objects that have a property whose value matches one of multiple values.

The disadvantage of this operator has always been that it only worked using parameters. Finally, since Adam 4.5.1 this has changed. Two very minor features have been added that make this operator much more easy to use. First, it now also works without parameters and second, the ToString-method of a SearchExpression-class now also properly returns a string representation of the values specified for the IN operator even if this was done using parameters.

The first new feature means that you can now do this:

C#
1
2
3
4
SearchExpression expr = new SearchExpression(
  "name in '\"test.jpg\", \"hello.jpg\"'");
UserCollection users = new UserCollection(app);
users.Load(expr);

The fact that you can now use the IN operator without using parameters means that they can now be typed in in forms in the Config Studio. To do that, simply create a comma separated list of double quoted values and quote this string using single quotes as you can see in the example above.

The second feature means that calling ToString on the search expression

C#
1
2
new SearchExpression("name in ?", new object[] { 
  new string[] { "test.jpg", "hello.jpg" } })
now returns "name in '\"test.jpg\", \"hello.jpg\"'". Why is this useful? Well because the IN operator was the reason why in previous versions of ADAM you weren't able to reliably store a string representation of a SearchExpression. Suppose you want to store a search expression typed in by a user in a database so that you can execute it again later on, then you couldn't do that if this SearchExpression contained an IN-operator. As of Adam 4.5.1, this is possible. You can now store the result returned by the ToString-method in a database. This string will contain the actual search expression and the parameter values, but it will not contain other properties of the search expression like whether or not wildcards are used, the languages specified...

Comments

Leave a comment
You must be logged in to post comments.
Sign in now
 
 
Technical
Business
rss feed