args.PrefetchPath is null

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 11-May-2009 19:51:35   

Hi there,

I'm trying to set a Prefetch Path on a PerformSelectEventArgs2 instance but the property is read only and null at runtime.

How do I make the property to be non-null?

Cheers, Ian.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-May-2009 04:11:34   

Hi Ian,

This is a get-only property. You don't need to write it, as normally you do one of two things:

  1. Set the property somewhere else (Page_Load, for instance). Then at PerformSelect you simply pass the e.PrefetchPath param.
_myLLBLGenProDataSource.PrefetchPathToUse = ...
adapter.FetchEntityCollection(e.ContainedCollection, null, e.PrefetchPath);
  1. At PerformSelect event handler, create a new PrefetchPath object and pass it to the fetch call:
protected void myLLBLGenProDataSource_PerformSelect(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2 e)
{
    PrefetchPath myPrefetchPath = new PrefetchPath(...);
    myPrefetchPath.Add(...);
    
    using (DataAccessAdapter adapter = new DataAccessAdapter())
    {
        adapter.FetchEntityCollection(e.ContainedCollection, null, myPrefetchPath);
    }
}

So, there is no need to write this event param.

David Elizondo | LLBLGen Support Team