How to set filter on PrefetchPath relation?

Posts   
 
    
Gabor
User
Posts: 97
Joined: 29-Jan-2005
# Posted on: 14-Apr-2005 12:44:02   

Hi,

I have two tables

The parent is Project and the child is ProjectAccount

I want to download the specific record from Project, with the ProjectAccount object that has a specific date.

The code is:

Dim PrefetchPath as IPrefetchPath2=New PrefetchPath2(CType(EntityType.ProjectEntity, Integer))

dim MyProject as New ProjectEntity(projectID)

Dim filter as IRelationPredicateBucket=New RelationPredicateBucket

filter.PredicateExpression.Add(PredicateFactory.Between( _ ProjectAccountFieldIndex.Date, _ elszamolasDate.AddDays(-1), _ elszamolasDate.AddDays(1)))

PrefetchPath.Add(ProjectEntity.PrefetchPath.ProjectAccountCol, 1, filter)

Here I get an Invalid Cust Exception.

I tried to ad the relation to MyProject, and then ad the relation to the filter, but the result was the same.

What amI missing?

Thanks

Gabor

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 14-Apr-2005 13:10:49   

Could you paste the stacktrace where you got the invalid cast exception?

Frans Bouma | Lead developer LLBLGen Pro
Gabor
User
Posts: 97
Joined: 29-Jan-2005
# Posted on: 14-Apr-2005 14:23:09   

Frans,

The newbiest question smile :

How to get the stacktrace, to show the LLBLGen parth oft the code?

Thanks

Gabor

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 14-Apr-2005 15:02:47   

Gabor wrote:

Frans,

The newbiest question smile :

How to get the stacktrace, to show the LLBLGen parth oft the code?

Thanks

Gabor

That stack trace is given with the exception by .NET simple_smile . (you know, that long list of "at .... " lines)

Frans Bouma | Lead developer LLBLGen Pro
Gabor
User
Posts: 97
Joined: 29-Jan-2005
# Posted on: 14-Apr-2005 16:20:23   

Thanks Frans,

That stack trace is given with the exception by .NET . (you know, that long list of "at .... " lines)

The list not so long confused

{System.InvalidCastException} [System.InvalidCastException]: {System.InvalidCastException} HelpLink: Nothing InnerException: Nothing Message: "Specified cast is not valid." Source: "BLL" StackTrace: " at BLL.queryMan.GetProjectAndElszamolas(DataAccessAdapter& adp, Int32 projectID, DateTime elszamolasDate) in C:\VB7projectek\MunkaElszamolo\BLL\queryMan.vb:line 606" TargetSite: {System.Reflection.RuntimeMethodInfo}

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 14-Apr-2005 17:04:24   

So what's at this line: C:\VB7projectek\MunkaElszamolo\BLL\queryMan.vb:line 606 There the invalid cast is performed. Could you paste that code here please?

Frans Bouma | Lead developer LLBLGen Pro
Gabor
User
Posts: 97
Joined: 29-Jan-2005
# Posted on: 14-Apr-2005 23:59:18   

Found the solution,

My mistake was, that I added a relationPredicateBucket to the filter property of the prefetch collection instead of predicateExpression.

Thanks

Gabor

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 15-Apr-2005 09:24:22   

Glad it's solved! simple_smile

Frans Bouma | Lead developer LLBLGen Pro