IEntityCollection.FindMatches issue

Posts   
 
    
astrouk
User
Posts: 53
Joined: 13-Jun-2006
# Posted on: 24-Jan-2007 01:57:42   

Hello,

I am experiencing a pretty strange issue with FindMatches method, which I use pretty often.

Let's examine the following simple code sample:


PersonLoginCollection collection = new PersonLoginCollection();
collection.GetMulti(new PredicateExpression(PersonLoginFields.PersonId == 14512));
List<int> list = collection.FindMatches(new PredicateExpression(PersonLoginFields.Icheck == 0));

list.Count = 0 (correct answer is list.Count = 1)

while code below returns correct result


PersonLoginCollection collection = new PersonLoginCollection();
collection.GetMulti(new PredicateExpression(PersonLoginFields.PersonId == 14512) & new PredicateExpression(PersonLoginFields.Icheck == 0));

collection.Count = 1

I have checked underlying sql query which corresponds to second code chunk. Both predicates are correct.

Can you tell me what's wrong with first method? Aren't they supposed to produce the same result? It works properly, if I use FindMatches with predicates by the fields other than PersonLoginFields.Icheck.

LLBLGenPro 2.0 (Dec 06, 2006) Selfservicing

Thank you

Alex

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 24-Jan-2007 03:02:10   

I don't see the problem with how you are using FindMatches. Are you certain that the GetMulti returned values?

Here's my code that returns all employees and then finds just the one with "Tester".

EmployeeCollection employees = new EmployeeCollection();
employees.GetMulti(null);
List<int> employeeIndicies = employees.FindMatches(EmployeeFields.Name == "Tester");
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 24-Jan-2007 11:33:41   

Is Icheck a short, or long field? (i.e. not an int32) ? In-memory filtering uses exact types. As '0' is an int32, it thus won't match with an int64 or int16 field. This will be corrected in v2.1. To work around this issue, cast the 0 to the proper type.

Frans Bouma | Lead developer LLBLGen Pro
astrouk
User
Posts: 53
Joined: 13-Jun-2006
# Posted on: 24-Jan-2007 20:00:44   

Otis wrote:

To work around this issue, cast the 0 to the proper type.

It has helped. Thank you, Frans.

Alex