.NET Connector filtering using Custom SQL

Is it possible to use BeforeSelect event for filtering when using a Custom SQL command? Code snippet below.

            public override IdhtmlxConnector CreateConnector(HttpContext context){
                ....
                connector = new dhtmlxGridConnector(
                    sql,
                    primaryKey,
                    dhtmlxDatabaseAdapterType.Odbc,
                    ConfigurationManager.ConnectionStrings["ODBC"].ConnectionString + db_schema,
                    extra,
                    false
                );
                connector.BeforeSelect += new EventHandler(connector_BeforeSelect);
                ....
            }
            void connector_BeforeSelect(object sender, EventArgs e)
            {
                ....
                // exception because  this.Connector.Request.Rules is null
                this.Connector.Request.Rules.Add(new FieldRule(var, op, val)); 
                ....
            }

If this is not possible, is there a way to safely sanitize user input? I’ve used OdbcCommand with parameters [e.g. comm.Paramaters.Add(“@input1”, “%'”)] and hopefully there is a mechanism like this

Hello,
Rules should work with custom sql, and you can add it with BeforeSelect event.
Please, try the attached version of the connectors. Does the issue happens there?
dhtmlxConnectors_121001.zip (275 KB)