Predicate problem

Posts   
 
    
ronny
User
Posts: 5
Joined: 07-Feb-2007
# Posted on: 15-Feb-2007 12:46:02   

First of some version info: - Version: LLBLGen Pro 2.0.0.0 - RTL: 2.0.0.61205 - DB: SQL 2005 - Template: Adapter with .Net 2.0

I'm experiencing a strange problem implementing a simple filter.. I want to load some data based on a couple of parameters. 2 of the 3 parameters are applied succesfully: dayid and active is true. The parameter planGroupDayId is not applied.

The code:

public void LoadData(Guid planGroupDayId) { <snip irrelevant code> IPredicateExpression filter = new PredicateExpression(); filter.Add(GroupsDaySlotsFields.PlanGroupDayId == planGroupDayId); filter.Add(GroupsDaySlotsFields.DayId == dayid); filter.Add(GroupsDaySlotsFields.Active == true); DataAccessWCF.FetchEntityCollection( this.entityCollection, filter); <snip irrelevant code> }

When i change the plangroupdayid parameter to the literal value, the filter is applied succesfully: filter.Add(GroupsDaySlotsFields.PlanGroupDayId == new Guid("759588b2-56e4-45c7-8a24-7b617bcd38ba"));

I have to say that i'm using llblgen the past 3 month now and applied many filters but not experienced this before.

Hopefully you guys can help me out cus this is very frustrating..

Thanks ronny

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 15-Feb-2007 15:49:08   
ronny
User
Posts: 5
Joined: 07-Feb-2007
# Posted on: 16-Feb-2007 08:15:30   

Thanks for the solution, but i am curious why this is happing.. In the past 3 months i have made dozens of similar filters, and all of them function properly. Only this one is not functioning. i still find it very strange..

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 16-Feb-2007 09:50:56   

When you enable DQE tracing, what's the query look like, is the parameter sent with the query? Also, the parameter you pass into the method, is that having a value or is that guid empty?

Frans Bouma | Lead developer LLBLGen Pro
ronny
User
Posts: 5
Joined: 07-Feb-2007
# Posted on: 16-Feb-2007 13:10:01   

I have enabled the SQL server profiler and i have some strange results. The query sent to sql server is below:

exec sp_executesql N'SELECT [databaseName].[dbo].[Groups.DaySlots].[ID] AS [Id], [databaseName].[dbo].[Groups.DaySlots].[ModifyUserID] AS [ModifyUserId], [databaseName].[dbo].[Groups.DaySlots].[Active], [databaseName].[dbo].[Groups.DaySlots].[DayID] AS [DayId], [databaseName].[dbo].[Groups.DaySlots].[QuarterNumber], [databaseName].[dbo].[Groups.DaySlots].[FormatID] AS [FormatId], [databaseName].[dbo].[Groups.DaySlots].[BoxID] AS [BoxId], [databaseName].[dbo].[Groups.DaySlots].[DaySlotType], [databaseName].[dbo].[Groups.DaySlots].[CommercialFormatID] AS [CommercialFormatId], [databaseName].[dbo].[Groups.DaySlots].[PlanGroupDayID] AS [PlanGroupDayId] FROM [databaseName].[dbo].[Groups.DaySlots] WHERE ( ( ( [databaseName].[dbo].[Groups.DaySlots].[PlanGroupDayID] = @PlanGroupDayId1 AND [databaseName].[dbo].[Groups.DaySlots].[DayID] = @DayId2 AND [databaseName].[dbo].[Groups.DaySlots].[Active] = @Active3)))',N'@PlanGroupDayId1 uniqueidentifier,@DayId2 uniqueidentifier,@Active3 bit',@PlanGroupDayId1='759588B2-56E4-45C7-8A24-7B617BCD38BA',@DayId2='A033AE0F-564E-4D70-8011-52C261C0AF2F',@Active3=1

When i paste this sql code in SQL server, i get 1 record as result, just as expected. But in in my entitycollection i get 2 results.... 1 entity which i expected but 1 entity with another plangroupdayid then past in the filter...

Very strange...

Feedback very much appreciated!

ronny
User
Posts: 5
Joined: 07-Feb-2007
# Posted on: 16-Feb-2007 15:05:04   

Problem Solved.

I didnt clear the entitycollection before i fetched the new results.... flushed Sorry, to bother you guys with a stupid error like this, i really need a vacation... cry

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-Feb-2007 15:07:24   

I was just gonna suggest you try clear the entityCollection. No problem, things like this always happen.