daelmo wrote:
Hi John,
jmcjq2 wrote:
if (!string.IsNullOrEmpty(ClientName))
{
bucket.PredicateExpression.Add(new FieldLikePredicate(ClientFields.Surname, null, "%" + ClientName + "%"));
}
Are you sure that the data in DB satisfy the filter criteria? I mean, your sql code works in SQL analyzer with that parameters?
Then, are you sure you are filtering the correct field? you are using ClientFields.Surname, but What is passed to ClientName parameter?
Examine the Generated SQL to know if everything is ok with that.
Hi,
I finally figured out what's causing the problem but yet to get the correct predicateexpression(s) to make it work.
The problem is the negate property is applied to the whole WHERE clause rather than just one of the expressions or in the other case not applied to the whole WHERE clause depending on which expression was last added.
bucket.PredicateExpression.Add(new FieldCompareRangePredicate(ClientFields.ClientId, null, participantArray)).Negate = true;
bucket.PredicateExpression.Add(new FieldLikePredicate(ClientFields.Surname, null, "%" + ClientName + "%")).Negate = false;
So instead of
WHERE ( NOT ( [BTA_DEVT].[dbo].[Client].[ClientId] IN (1)) AND [BTA_DEVT].[dbo].[Client].[Surname] LIKE '%Smith%')
it generates this
WHERE ( NOT ( [BTA_DEVT].[dbo].[Client].[ClientId] IN (1) AND [BTA_DEVT].[dbo].[Client].[Surname] LIKE '%Smith%')
The subtle difference is the extra ")" before the AND clause, how do I make the negate property to apply only to the expression it's attach to?
Thanks in advance
John