Introducing support for Flexible Operators

In release 7.8 Xomega has tremendously improved support for operators that are used to build search forms and LINQ queries.

Thanks to the framework support, using operators to build LINQ queries takes just a single line of code now. The framework comes loaded with standard operators for common data types, as well as dynamic operators for ranges of (relative) dates and numbers. Plus, it allows you to implement and plug in your own operators or override the behavior of any of the built-in operators.

Read on to learn more about these powerful features.

Framework to support operators for building queries.

While Xomega supported operators for query operations before, it was using a predefined list of operators, and each operator was handled explicitly for each criteria in the generated service, which resulted in a rather bloated and inflexible generated class.

With addition of the operators support to the Xomega Framework, including in the BaseService class, handling any criteria with operators takes just one line in the service now. Not only does it make the generated code much more cleaner, but it also helps writing custom code for non-standard criteria so much easier.

Standard operators for common data types.

Xomega Framework provides implementation for most of the standard operators on the common data types, such as Is Null, Equals To, Less Than and Greater Than, Between etc., including the corresponding inverse operators.

You can also develop and register your own implementation of any custom operator, or even override implementation of any of the standards operators.

Dynamic operators for date ranges using relative dates.

In addition to the standard predefined operators, Xomega Framework supports dynamic operators for date ranges. For each upper/lower bound of the range you can use either an absolute date or a relative date, such as ‘ct’ for the current time, ‘bo(s/m/h/d/w/M/y)’ for the beginning of second, minute, hour, day, week, month or year respectively, or the ‘eo(s/m/h/d/w/M/y)’ for the end of the same period.

You can further adjust it by adding or subtracting a certain number of periods, e.g. -60d to subtract 60 days, and also indicate whether you want to include or exclude the bound by using either square brackets or parentheses respectively.

For example, Xomega supplies the following standard dynamic range operators for relative  dates, but you are free to define your own operators like that in your Xomega model.
      <item name="Today" value="[bod,eod)"/>
      <item name="This Week" value="[bow,eow)"/>
      <item name="This Month" value="[boM,eoM)"/>
      <item name="This Year" value="[boy,eoy)"/>
      <item name="Last 30 Days" value="[bod-30d,ct]"/>

Dynamic operators for number ranges.

Similar to the date ranges, Xomega Framework also supports dynamic operators for numeric ranges. So, for certain numeric fields you may want to let the user select criteria for some  predefined ranges instead of, or in addition to, manually supplying the From and To values.

For example, to filter something by price you can define low, medium, and high price ranges,  which you can call  Budget, Average and Luxury respectively, as follows.
      <item name="Budget" value="[0,100)"/>
      <item name="Average" value="[100,1000)"/>
      <item name="Luxury" value="[1000,)"/>

These operators do not require additional values, and are more convenient for the user. If none of your operators for a certain field require additional values, then you can also make the operator parameter multi-value in the Xomega model, which will allow the user to filter by multiple ranges at the same time.

No comments:

Post a Comment