Actually the prefetch path you are talking about is created using an IPrefetchPath2:
// prepare prefetch (order -> shipMethod, order -> employee)
IPrefetchPath2 myOrderPath = new PrefetchPath2((int)EntityType.PurchaseOrderEntity);
myOrderPath.Add(PurchaseOrderEntity.PrefetchPathShipMethod);
myOrderPath.Add(PurchaseOrderEntity.PrefetchPathEmployee);
...
var qq = (from o in metaData.PurchaseOrder
where o.PurchaseOrderId == 4002
select o).WithPath(myOrderPath).First();
... from LLBLGen'ing:
LLBLGen'ing wrote:
... Note that we are passing a PrefetchPath object to the WithPath method extension. This demonstrates that the IPrefetchPats are totally reusable, even in path-edged linq2llbl code.
So, to answer your question: yes, you can use that PrefetchPath instance as a variable or as a return type in a method and re-use it in a PathEdge's LINQ2LLBL query or with a LLBLGen API object:
private IPrefetchPath2 GiveMeTheOrderPath()
{
IPrefetchPath2 pathToReturn= new PrefetchPath2((int)EntityType.PurchaseOrderEntity);
pathToReturn.Add(PurchaseOrderEntity.PrefetchPathShipMethod);
pathToReturn.Add(PurchaseOrderEntity.PrefetchPathEmployee);
return myOrderPath;
}
...
var orderPath = GiveMeTheOrderPath();
adapter.FetchEntityCollection(myOrders, null, orderPath );
...
var qq = (from o in metaData.PurchaseOrder
select o).WithPath(orderPath ).First();