Prefetch

Posts   
 
    
Noer
User
Posts: 33
Joined: 04-Jan-2007
# Posted on: 03-May-2007 15:34:32   

Hi,

The folowing code is not valid because DispatchListEntity.PrefetchPathDispatch appears 2 times.

IPrefetchPath prefetch = new PrefetchPath((int)EntityType.DispatchListEntity);

            prefetch.Add(DispatchListEntity.PrefetchPathDispatch).SubPath.Add( DispatchEntity.PrefetchPathAddressDestination).SubPath.Add( AddressEntity.PrefetchPathZipCode).SubPath.Add( ZipCodeEntity.PrefetchPathAreaDefinition).SubPath.Add(AreaDefinitionEntity.PrefetchPathRegion);
            prefetch.Add(DispatchListEntity.PrefetchPathDispatch).SubPath.Add( DispatchEntity.PrefetchPathAddressPickup).SubPath.Add( AddressEntity.PrefetchPathZipCode).SubPath.Add( ZipCodeEntity.PrefetchPathAreaDefinition).SubPath.Add( AreaDefinitionEntity.PrefetchPathRegion);

How do I get it right?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-May-2007 15:46:45   

Use a prefetchPathElement as follows:

            PrefetchPathElement2 prefetchDispatch = DispatchListEntity.PrefetchPathDispatch;

            prefetchDispatch.SubPath.Add(DispatchEntity.PrefetchPathAddressDestination).SubPath.Add( AddressEntity.PrefetchPathZipCode).SubPath.Add( ZipCodeEntity.PrefetchPathAreaDefinition).SubPath.Add( AreaDefinitionEntity.PrefetchPathRegion);
            prefetchDispatch.SubPath.Add(DispatchEntity.PrefetchPathAddressPickup).SubPath.Add( AddressEntity.PrefetchPathZipCode).SubPath.Add( ZipCodeEntity.PrefetchPathAreaDefinition).SubPath.Add( AreaDefinitionEntity.PrefetchPathRegion);

            IPrefetchPath prefetch = new PrefetchPath((int)EntityType.DispatchListEntity);
            prefetch.Add(prefetchDispatch);
Noer
User
Posts: 33
Joined: 04-Jan-2007
# Posted on: 03-May-2007 16:12:47   

This:

PrefetchPathElement2 prefetchDispatch = DispatchListEntity.PrefetchPathDispatch;

returns the folowing error:

Cannot implicitly convert type 'SD.LLBLGen.Pro.ORMSupportClasses.IPrefetchPathElement' to 'SD.LLBLGen.Pro.ORMSupportClasses.PrefetchPathElement2'. An explicit conversion exists (are you missing a cast?)

If I try this:

PrefetchPathElement2 prefetchDispatch = (PrefetchPathElement2)DispatchListEntity.PrefetchPathDispatch;

Then this line:

prefetchDispatch.SubPath.Add(DispatchEntity.PrefetchPathAddressDestination).SubPath.Add( AddressEntity.PrefetchPathZipCode).SubPath.Add(ZipCodeEntity.PrefetchPathAreaDefinition).SubPath.Add( AreaDefinitionEntity.PrefetchPathRegion);

returns:

The best overloaded method match for 'SD.LLBLGen.Pro.ORMSupportClasses.IPrefetchPath2.Add(SD.LLBLGen.Pro.ORMSupportClasses.IPrefetchPathElement2)' has some invalid arguments
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-May-2007 18:17:04   

Oh sorry, just remove the '2' from the end of the class name. IPrefetchPathElement2 is used in the Adapter model.

So if you are using the SelfServicing model then the following should be correct:

PrefetchPathElement prefetchDispatch = DispatchListEntity.PrefetchPathDispatch;