public class PostgreStringLengthFilter : IDbFilterFunction
/// Gets the provider name, in our case PostgreSQL
public string Provider => "npgsql";
/// Gets the name of the transform
public string Name => "length_difference";
/// Create a SQL statement
public SqlStatement CreateSqlStatement(SqlStatement current, string filterColumn, string[] parms, string operand, Type operandType)
// Match an operand to support less than or equal to semantics
var match = new Regex(@"^([<>]?=?)(.*?)quot;).Match(operand);
String op = match.Groups[1].Value, value = match.Groups[2].Value;
if (String.IsNullOrEmpty(op)) op = "=";
return current.Append(quot;ABS(LENGTH({filterColumn}) - LENGTH(?)) {op} ?", QueryBuilder.CreateParameterValue(parms[0], operandType), QueryBuilder.CreateParameterValue(value, typeof(Int32)));