FindMatches returns wrong number of matches

Posts   
 
    
TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 04-Jun-2009 08:29:33   

Hi,

I'm using LLBLGenPro runtime of 12th May and I have a strange issue.

I use FindMatches on an EntityCollection and the result is wrong. I attached a screenshot of my watch window. I have an entitycollection with 3 elements. I used following statement:


indices = TimeSliceGroups.FindMatches(MemoryEm3200TimeSliceGroupFields.TimeSliceGroupBits == pData.TimeSliceGroupBits & MemoryEm3200TimeSliceGroupFields.Deleted == 0 & MemoryEm3200TimeSliceGroupFields.ExternalIdlink == 0);

This result in indices.Count == 0. Although when I change the filter into (I removed the MemoryEm3200TimeSliceGroupFields.Deleted == 0 part)


indices = TimeSliceGroups.FindMatches(MemoryEm3200TimeSliceGroupFields.TimeSliceGroupBits == pData.TimeSliceGroupBits & MemoryEm3200TimeSliceGroupFields.ExternalIdlink == 0)

I get a count of 1. It says me that the element with index 2 is a match. When I then ask the Deleted value of the element of position 2 I get that the value is 0. So it should also be found by the first predicate.

Btw, it's a boolean field and I already tried the filter with the false value. Same result.

I don't have any problems with FindMatches before so I probably did something wrong. Does any of you have any idea?

Kind regards, TomV

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 04-Jun-2009 09:17:30   

Would you please try the following code:

IPredcate filter = new PredicateExpression();
filter.Add(MemoryEm3200TimeSliceGroupFields.TimeSliceGroupBits == pData.TimeSliceGroupBits);
filter.Add(MemoryEm3200TimeSliceGroupFields.Deleted == false);
filter.Add(MemoryEm3200TimeSliceGroupFields.ExternalIdlink == 0);

indices = TimeSliceGroups.FindMatches(filter);
TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 04-Jun-2009 09:40:29   

Hi Walaa,

I tried following code:


IPredicate filter = new PredicateExpression();
            
filter.Add(MemoryEm3200TimeSliceGroupFields.TimeSliceGroupBits == pData.TimeSliceGroupBits);
filter.Add(MemoryEm3200TimeSliceGroupFields.Deleted == false);
filter.Add(MemoryEm3200TimeSliceGroupFields.ExternalIdlink == 0);

indices = TimeSliceGroups.FindMatches(filter);

but I receive following error:

Error 230 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicate' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicate' could be found (are you missing a using directive or an assembly reference?)

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 04-Jun-2009 09:48:17   

Sorry, try this instead:

IPredicateExpression filter = new PredicateExpression();
TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 04-Jun-2009 10:02:00   

Hi Walaa,

I'm afraid it has the same result. I also created a filter2 via my immediate window (without the deleted == false statement) and the count is 1.

So both ways react identically.

I attached another screenshot of what I did.

Can this be linked to my code in some way? I never had problems before with predicate(expressions).

Regards, TomV

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jun-2009 04:54:31   
David Elizondo | LLBLGen Support Team
TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 05-Jun-2009 07:26:29   

HI Daelmo,

It's the latest runtime available, the one of 12th of May 2009 file version of SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll is 2.6.9.511. It's indeed an entity that is a child of a base entity which works with a discriminator. The deleted field is a normal boolean field, nothing special about that.

Regards, TomV

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 05-Jun-2009 08:54:04   

Would you please cook a small and simple repro solution for us and attach it here?

Thanks.

TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 05-Jun-2009 09:01:23   

Hi Walaa,

Sure I'm willing to do so, but as I stated before I never had any problems with the predicate expressions before, or at least not that I noticed so far. So when I create a repro solution it will probably work.

And also, just like everybody else in here our application is very complex sunglasses

Can I do anything else to give you guys more information. It's not a big thing if I have to change my BL like I did yesterday.

Kind regards, TomV

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 05-Jun-2009 09:12:45   

I believe you, that's the same thing over here, we won't be able to reproduce it. But maybe if you can extract this entity and collection into a new project and send it over. Don't start a repro from scratch, just copy the lgp project file into another place, open it and remove all un-needed entities, and just leave the relevant ones. Generate the code, and then create a new console application or a test dll project. And try to repro the same behaviour, calling FindMatches(), and then send this solution over.

For Privacy: you can either open a Helpdesk thread and attach the solution there, or mail it to: support AT llblgen DOT com, and mention this thread in your mail.

TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 05-Jun-2009 09:15:02   

Hi Walaa,

I started a new console app and you can see the result in attachment. Maybe you can already see in that code if I do something wrong or make a insane assumption :-)

If not I will do what you asked. Or would you have enough with this solution?

Update: Please notice that there was a copy - paste error in my previous screenshot! I always used ts1 to set the values, so off course there was only 1 match. I'm now creating the stripped down lgp and console app as you requested...

Kind regards, TomV

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 05-Jun-2009 10:22:36   

Hang on.

I was able to reproduce it.

I was mistaken, I couldn't reproduce it using the following Northwind code:

            ProductsCollection products = new ProductsCollection();
            ProductsEntity product1 = new ProductsEntity();
            product1.ProductName = "PR1";
            product1.UnitPrice = 10;
            product1.Discontinued = true;
            products.Add(product1);

            ProductsEntity product2 = new ProductsEntity();
            product2.ProductName = "PR2";
            product2.UnitPrice = 20;
            product2.Discontinued = false;
            products.Add(product2);

            ProductsEntity product3 = new ProductsEntity();
            product3.ProductName = "PR3";
            product3.UnitPrice = 30;
            product3.Discontinued = true;
            products.Add(product3);

            List<int> indices = products.FindMatches((ProductsFields.UnitPrice > 10) & (ProductsFields.Discontinued == false));

Which always return the correct count based on the data specified. I tried increasing the entities and the count of false fields, and FindMatches always gave me the correct count.

TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 05-Jun-2009 10:37:58   

Hi Walaa,

I created a repro console app and was able to simulate. I will create a HelpDesk thread and post it for privacy reasons.

Kind regards, TomV

TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 05-Jun-2009 10:47:46   

Hi Walaa,

Thread created in helpdesk forum with guidelines how to simulate, and project uploaded.

Kind regards, TomV

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 05-Jun-2009 12:27:52   

Continued in helpdesk thread.

Frans Bouma | Lead developer LLBLGen Pro