Extending EntityCollectionBase

Posts   
 
    
bmila
User
Posts: 2
Joined: 24-Jan-2007
# Posted on: 24-Jan-2007 21:40:26   

Hello,

We are trying to replace our homebuilt data access layer with LLBLGen. We have base entity collection that all our collection classes inherit from.

public class MyCollection : BaseCollection 
{
}

Same thing for our Entity classes. Using LLBLGen I have been able to replicate much of the functionality that was in the subclassed entity and collection classes. But we also have many functions that take our base collection class an argument and then call methods like:

public void Remove(BaseCollection collection, BaseEntity entity)
{
    if (BaseCollection.Find( Entity ))
    {
       BaseCollection .Delete ( Entity )
    }
}

We have hundreds of functions that take the BaseCollection or BaseEntity as a parameter and call methods are not present in LLBLGen. cry

Is there a way to add functionality to the IEntityCollection or EntityCollectionBase classes? I need some way of putting in some code to the base collection class to mimic the behavior we already have in place.

As far as I can tell (I have not been working with LLBLGen very long), there is no way to add code to anything that is in the SD.LLBLGen.Pro.ORMSupportClasses namespace. Has anyone else run into this and, if so, what is the recommended solution?

We are using LLBLGen Pro 2.0, Self Servicing.

Brian

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 25-Jan-2007 02:38:14   

The best I can think of is to have your BaseCollection inherit from IEntityCollection and then have the generated collection classes inherit from your BaseCollection. Then do the same for entities. The generated classes can have this built into them by modifying their templates.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 25-Jan-2007 10:44:08   

What kind of functionality do you want to get added? You have three choices: a customer can alter the EntityCollectionBase<T> class in teh sourcecode of the runtime lib, or you can add the code to the template which is used to generate the collection classes. I'd go for option one if the functionality is shared among all classes.

Though perhaps the functionality is already build in, could you explain a bit what you want to get added?

Frans Bouma | Lead developer LLBLGen Pro
bmila
User
Posts: 2
Joined: 24-Jan-2007
# Posted on: 25-Jan-2007 23:54:18   

You have three choices: a customer can alter the EntityCollectionBase<T> class in teh sourcecode of the runtime lib

We have access to the source? Sweet! I see the source now and have started making good progress adapting the functions. Thanks!

Though perhaps the functionality is already build in, could you explain a bit what you want to get added?

Its not so much that the functionality doesn't exist in LLBLGen, its that we named things differently. Your base find method is FindMatches(IPredicate), ours is Find( PrimaryKey ). We have our own custom error collection class. We also have a CollectionExtender class that allows us to extend a collection with non-database fields so that we can add fields and then bind to that collection with extra fields.

Basically, its a hack job to get the rip out our custom DAL, then put in LLBLGen. But the rest of the team is on hold until I get the app up and running with this piece so I need to force our code in and then go back and make changes to use the LLBLGen provided methods.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Jan-2007 08:42:48   

Well, Good Luck.