Question about creating IPrefetchPathElement2's

Posts   
 
    
Posts: 5
Joined: 01-Mar-2009
# Posted on: 07-Mar-2009 09:02:38   

Is it possible to create IPrefetchPathElement2's with just an Entity as it's "anchor" instead of a path.

Basically, I want a class full of canned prefetches that I can just add to my queries.

i.e.


public static class CannedPrefetches
{
   public static IPrefetchPathElement2 UserWithTypeAndSubType
        {
            get
                            {
                                 IPrefetchPathElement2 _prefetchElem = UserEntity.PrefetchPathStaff; // Problem here
                                 prefetchElem.SubPath.Add(....
                                 prefetchElem.SubPath.Add(....
                                 prefetchElem.SubPath.Add(....

                                 return prefetchElem;
                           } 
               }
}

Then to use it, I can do something like


IPrefetchPath2 _prefetch = new PrefetchPath2((int)EntityType.UserEntity);
_prefetch.Add(CannedPrefetches.UserWithTypeAndSubType);

My problem is the creation of the IPrefetchPathElement2 requires a walk from one entity to the other and it "landed" on the path destination. I can't hang things with SubPath off the UserEntity in this case, only the StaffEntity.

Is there anyway to do what I want with this canned prefetch idea? Or did what I'm trying to explain even make sense?

thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Mar-2009 20:23:15   

I don't understand you 100%.

If I create a method:

public IPrefetchPathElement2 GetCustomerOrdersSubPath()
{
    IPrefetchPathElement2 customerOrdersPath = CustomerEntity.PrefetchPathOrders;
    customerOrdersPath.SubPath.Add(OrderEntity.PrefetchPathEmployee);
    customerOrdersPath.SubPath.Add(OrderEntity.PrefetchPathOrderDetails);

    return customerOrdersPath;
}

and then I use it in my code:

IPrefetchPath2 path = new PrefetchPath2((int) EntityType.CustomerEntity);
path.Add(GetCustomerOrdersSubPath());

CustomerEntity customer = new CustomerEntity("ALFKI");
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
    adapter.FetchEntity(customer, path);
}

It works just nice. What is the problem with yours? Could you please elaborate more? LLBLGen version and runtime library version (http://llblgen.com/tinyforum/Messages.aspx?ThreadID=7722)?

David Elizondo | LLBLGen Support Team