PredicateBuilder issue with ServiceStack OrmLite -
i using servicestack ormlite predicatebuilder build statement dynamically:
var q = predicatebuilder.true<itemlist>(); if (!filter.keyword.isnullorwhitespace()) { q = q.and(i => i.brand.contains(filter.keyword) || i.itemdescription.contains(filter.keyword) || i.serial.contains(filter.keyword)); } if (!filter.itemstatus.isnullorwhitespace()) { q=q.and(i => i.itemstatus == filter.itemstatus); } var count = await db.countasync(db.from<itemlist>().where(q));
if none of if statements conditions met, error on executing query:
an expression of non-boolean type specified in context condition expected, near 'order'
the reason query generated is:
select [list of fields] itemlist true
update: using sql server 2012 dialect provider.
and not valid, expected behaviour?
i can use boolean check if condition being met , apply predicate expression, cumbersome.
i expecting if using predicate without added clause get:
where true=true
or equivalent.
is correct way of using predicatebuilder?
Comments
Post a Comment