Derived EntityCollection PrefetchPath

Posts   
 
    
Muttley
User
Posts: 18
Joined: 04-Jan-2007
# Posted on: 11-Sep-2008 23:03:54   

Using 2.6, Adapter, VS2008

After developing a few projects in a quite risk free setup using llblgen i'mexploring some posibilities to "really" use LLBLGen i'm stuck now on inherited EntityCollections

I want to kind of apply the repository pattern on entityCollections and therefore inherit from entitycollection and add some features.

Basically for example :


public class OrderDetailRepository : EntityCollection<OrderDetailEntity> 
{
     //some properties typically for OrderDetails like Sum ....
}

Now if i create a class like LoadOrders i want to use a prefetchpath and when using this prefetch path OrderDetails is an entityCollection but i would like to see it a "OrderDetailRepository" is there a way to achieve this quite easily ?

M.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 12-Sep-2008 10:15:06   

You may try to modify the generated code, to add a new method to the Order class to prefetchThe custom type, like this.

public static IPrefetchPathElement2 PrefetchPathOrderDetailRepository 

Copy the imlpementation code form the PrefetchPathOrderDetail method, but then you'll need to modify the EntityFactory used to use a custom one for the custom derived entity. Just create a new entityFactory (copy an existing one and modify the code to instantiate from the OrderDetailRepositoryEntity).

P.S Make sure all your custom code is placed inside existing user code regions or better in new partial class files.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 12-Sep-2008 11:36:00   

I think this is probably not what you want to do, as entities contain an instance of EntityCollection<T> and this will create parallel hierarchies.

So you should do either one of the two things: 1) add the repository code in a partial class of EntityCollection<T>. This is teh easiest way or 2) create a copy of the EntityCollection<T> template and change it to include your repository code. then create a templatebinding for your custom template and bind it to the same templateid as the original one. Place your templatebinding above the standard one (in tab 2 of the code generation configuration dialog. This will make llblgen pro to pick your template and generate code using your own template.

Frans Bouma | Lead developer LLBLGen Pro