private static EntitySchemaQueryFilter AddUpperFunctionFilter(EntitySchemaQuery esq, string columnName,
                                                                      string filterValue)
        {
            EntitySchemaQueryFunction upperNameFunction = esq.CreateUpperFunction(columnName);
            var filter = new EntitySchemaQueryFilter(FilterComparisonType.Equal)
            {
                LeftExpression = new EntitySchemaQueryExpression(upperNameFunction)
            };

            filter.RightExpressions.Add(new EntitySchemaQueryExpression(EntitySchemaQueryExpressionType.Parameter)
            {
                ParameterValue = filterValue.ToUpperInvariant()
            });
            esq.Filters.Add(filter);
            return(filter);
        }
        /// <summary>
        /// Adds length function filter for entity schema query to current filter collection.
        /// </summary>
        /// <param name="filterCollection">Filter collection, which the created filter will be added to.</param>
        /// <param name="schema">Entity schema.</param>
        /// <param name="columnName">Name of column, which should be operand for the function.</param>
        /// <param name="comparisonType">Type of comparison with function.</param>
        /// <param name="value">Value to compare function with.</param>
        /// <returns>Created compare filter like "LEN(column_name) comparison_type value".</returns>
        public static EntitySchemaQueryFilter AddLengthFilter(this EntitySchemaQueryFilterCollection filterCollection,
                                                              EntitySchema schema, string columnName, FilterComparisonType comparisonType, int value)
        {
            var esq = filterCollection.ParentQuery;
            EntitySchemaQueryFunction function = esq.CreateLengthFunction(
                EntitySchemaQuery.CreateSchemaColumnExpression(schema, columnName));
            var filter = new EntitySchemaQueryFilter(FilterComparisonType.Equal)
            {
                LeftExpression = new EntitySchemaQueryExpression(function),
                ComparisonType = comparisonType
            };

            filter.RightExpressions.Add(new EntitySchemaQueryExpression(EntitySchemaQueryExpressionType.Parameter)
            {
                ParameterValue = value
            });
            filterCollection.Add(filter);
            return(filter);
        }