Prefetch Path

Posts   
 
    
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 30-May-2007 18:04:09   

Hi All,

Having a problem with prefetch paths.

My database structure looks like this:

HpDataBase - 1:m -> HpDataSet HpDataSet - 1:m -> HpField - m:1 ->HpFieldType HpDataSet - 1:m -> HpCalculatedField - m:1 ->HpFieldType

Here is the code:

    Public Shared Function GetHpDataBase(ByVal hpDataBaseName As String) As HpDataBaseEntity

        Using Adapter As New DataAccessAdapter
            Dim HoldEntity As New HpDataBaseEntity

            Dim prefetchPathElement As PrefetchPathElement2 = CType(HpDataBaseEntity.PrefetchPathHpDataSet, PrefetchPathElement2)

            prefetchPathElement.SubPath.Add(HpDataSetEntity.PrefetchPathHpField).SubPath.Add(HpFieldEntity.PrefetchPathHpFieldType)
            prefetchPathElement.SubPath.Add(HpDataSetEntity.PrefetchPathHpCalculatedField).SubPath.Add(HpFieldEntity.PrefetchPathHpFieldType)

            Dim PrefetchPath As PrefetchPath2 = New PrefetchPath2(EntityType.HpDataBaseEntity)

            PrefetchPath.Add(prefetchPathElement)

            Adapter.FetchEntityUsingUniqueConstraint(HoldEntity, New PredicateExpression(HpDataBaseFields.DataBaseName = hpDataBaseName), PrefetchPath)
            Return HoldEntity
        End Using

    End Function

It's complaining with

The prefetch path element at index 0 in the passed in prefetch path for root entity type 0 is meant for root entity type 3 which isn't a subtype of 0. This means that you've added a prefetch path node to a Path of an unrelated entity, like adding OrderDetailsEntity.PrefetchPathProduct to a prefetch path for CustomerEntity.

Any help would be appreciated.

Fishy

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 30-May-2007 22:03:16   

I found the problem. The second subpath specified HpFieldEntity and it should have been HpCalcuulateFieldEntity.