Using PrefetchPath with Self-Service and LLBLGenProDataSource

Posts   
 
    
apb
User
Posts: 41
Joined: 21-Oct-2008
# Posted on: 04-Dec-2008 00:01:34   

Hi,

I'm working on a project where many of the grids will need to display fields from related tables.

I'm using 2.6 + self-servicing and declaratively bindng to controls with LLBLGenProDataSource.

From reading your documentation it seems self-servicing mode uses lazy-loading. Which is good for some cases, but really bad if you need the related fields loaded for each returned row.

My question is: how do I tell it to prefetch fields from a collection that is declaratively set in a LLBLGenProDataSource?

Thanks.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Dec-2008 06:04:16   

Even if the LLBLGenProDataSource is declarative, you have to specify the prefetchPath at code behind. For example:

protected void Page_Load(object sender, EventArgs e)
{
     if (!IsPostBack)
     {
          IPrefetchPath path = new PrefetchPath((int) EntityType.OrderEntity);
          path.Add(OrderEntity.PrefetchPathCustomer);
          path.Add(OrderEntity.PrefetchPathEmployee);

          theDataSource.PrefetchPathToUse = path;
     }
}

And that's it. The involded entities will be prefetched.

David Elizondo | LLBLGen Support Team
apb
User
Posts: 41
Joined: 21-Oct-2008
# Posted on: 04-Dec-2008 12:43:49   

Thanks.