Active Query Builder support area

QueryTransformer NullReferenceException while filtering

Avatar
  • updated
  • Completed

Hello,

I am working with c# and with AQB version 3.2.1.1033 and i just want to transform a provided sql by adding a filter. But when I add the filter, i am getting a NullReferenceException:


at ActiveQueryBuilder.Core.PrepareAndFixupVisitor.(AstNodeBase )
at ActiveQueryBuilder.Core.PrepareAndFixupVisitor.(AstNodeBase )
at ActiveQueryBuilder.Core.PrepareAndFixupVisitor.FixupInContext(AstNodeBase rootNode, IList`1 cteItems, IList`1 fromItems)
at ActiveQueryBuilder.Core.AstNodeBase.PrepareAndFixupRecursive(IList`1 cteList, IList`1 fromSourcesList)
at ActiveQueryBuilder.Core.QueryTransformer.QueryTransformer.(QueryRoot , Boolean )
at ActiveQueryBuilder.Core.QueryTransformer.QueryTransformer.()
at ActiveQueryBuilder.Core.QueryTransformer.QueryTransformer.get_ResultAST()
at ActiveQueryBuilder.Core.QueryTransformer.QueryTransformer.get_SQL()

My source code :

ActiveQueryBuilder.Core.SQLQuery query = new ActiveQueryBuilder.Core.SQLQuery();
SQLContext ctx = new SQLContext();
ctx.SyntaxProvider = new MSSQLSyntaxProvider();
query.SQLContext = ctx;
query.SQL = "SELECT ID, NAME FROM PARAMETER";
QueryTransformer t = new QueryTransformer();
t.QueryProvider = query;
t.AlwaysWrapInSubQuery = false;
t.OrderBy(t.Columns[0], false);
t.Where("NAME LIKE %A%");
string sql = t.SQL;

Am I doing something wrong or is it a bug? This excption is only thrown when i use the filtering. Just adding an order command works without problems.

Best regards,

Christian Sack


Avatar
Sergey Kraikov

Hello Christian,

thank you for detailed bug report.
You should quote %A% into single quotes:

t.Where("NAME LIKE '%A%'");

Anyway, I'll add the check to verify the string given to Where is valid SQL expression.

Avatar
pdv-software

Ok, it works now. Sorry for that stupid mistake. But thank you for your fast answer.

Avatar
Andrey Zavyalov, PM

Hello, Chris.

The Null-reference exception is fixed now.

You can download the new version in the Customer's area.