Page 1 of 1

Boolean filter

Posted: Sat 26 Dec 2015 09:31
by AudioPat
Hi,

How to filter a boolean field in linq in the where statement?
i've try the following examples:

Code: Select all

  LWhere := '(Container.Active = true)'; // Invalid expression (true)
  LWhere := '(Container.Active = '1');  // Invalid node type {46}
Another exception is throwed when you add a filter with more 'and' operations into a where filter.

This works fine:

Code: Select all

  LWhere := '(Relatie.Snelcode.Contains(''%' + edtSnelcode.text + '%''))' +
            ' and (Relatie.ZoekNaam.Contains(''%' + edtZoeknaam.text + '%''))';

This results into a EExpressionException(TQueryConverter - Invalid node type {0}).

Code: Select all

  LWhere := '(Relatie.Snelcode.Contains(''%' + edtSnelcode.text + '%''))' +
            ' and (Relatie.ZoekNaam.Contains(''%' + edtZoeknaam.text + '%''))'+
            ' and (Relatie.RelatieNaam.Contains(''%' + edtRelatienaam.text + '%''))';

Result string:

Code: Select all

  LWhere := '(Relatie.Snelcode.Contains(''%%'')) and (Relatie.ZoekNaam.Contains(''%%'')) and (Relatie.RelatieNaam.Contains(''%%''))'
Linq:

Code: Select all

  LQuery := From('Relatie').Where(LWhere).OrderBy('Relatie.Snelcode').Select();
  LList := DataContext.GetEntities<TRelatie>(LQuery).ToList;
Thanks.

Re: Boolean filter

Posted: Mon 28 Dec 2015 07:11
by AlexP
Hello,

Thank you for the information. We have reproduced the problem and will investigate the reasons of such behavior.