combit List & Label 30 - .NET Help
combit.Reporting.DataProviders Namespace / DbCommandSetDataProvider Class / TranslateFilterSyntax Event
Example


TranslateFilterSyntax Event (DbCommandSetDataProvider)

This event can be used to override the default filter syntax translation. It is called before the filter gets translated by List & Label. If the Result property is set to null, the default translation will be carried out. Otherwise, the result will be used as translation. See also IAdvancedFiltering Interface.

Syntax
'Declaration
 
Public Event TranslateFilterSyntax As EventHandler(Of TranslateFilterSyntaxEventArgs)
 
Event Data

The event handler receives an argument of type TranslateFilterSyntaxEventArgs containing data related to this event. The following TranslateFilterSyntaxEventArgs properties provide information specific to this event.

PropertyDescription
Number of arguments in case a function should be translated.  
Array of arguments. In case of operators, it contains the left hand and possibly the right hand side. In case of functions, the array holds the function's parameters as used in the Designer.  
Set to true to indicate that the event has been properly handled and no further default handling should be performed.  

Name to be translated. If argumentType is e.g. Text, this object contains an index and can be set to a string to use as parameter name instead. The value of the parameter is then passed to the ApplyAdvancedFilter Method later.

In case of RelationEqual to be translated, the name might be "@ARG:MULTIVALUE". In this case, the right hand side (Arguments[1]) contains a comma separated list of values to compare to.

 
The kind of expression that is to be translated.  
The translated expression or null if the default handling should be used.
 
 
Example

protected override void OnTranslateFilterSyntax(object sender, TranslateFilterSyntaxEventArgs e)
{
    switch (e.Part)
    {
        case LlExpressionPart.Function:
            switch (e.Name.ToString().ToUpper())
            {
                case "MID$":
                    if (e.ArgumentCount == 2)
                        e.Result = (String.Format("(SUBSTR({0},{1}))", e.Arguments[0].ToString(), e.Arguments[1].ToString() + "+1"));
                    else
                        e.Result = (String.Format("(SUBSTR({0},{1},{2}))", e.Arguments[0].ToString(), e.Arguments[1].ToString() + "+1", e.Arguments[2].ToString()));
                    e.Handled = true;
                    break;
                case "LEFT$":
                    e.Result = (String.Format("(SUBSTR({0},0,{1}))", e.Arguments[0].ToString(), e.Arguments[1].ToString()));
                    e.Handled = true;
                    break;
                case "RIGHT$":
                    e.Result = (String.Format("(SUBSTR({0},-{1},{1}))", e.Arguments[0].ToString(), e.Arguments[1].ToString()));
                    e.Handled = true;
                    break;
                default:
                    break;
            }
            break;
        default:
            break;
    }
}
Requirements

See Also