Entity Subclasses

Posts   
 
    
Chris187
User
Posts: 6
Joined: 11-Jul-2014
# Posted on: 25-Jul-2014 13:37:00   

Hi,

I read on the forum that I cannot change the name of the entities and that I should use subclasses instead.

So I created a subclass for each entity:


    public class First : FirstEntity { }
    public class Second: SecondEntity { }
    public class Third : ThirdEntity { }

Now I want to use First, Second and Third in my code instead of FirstEntity, SecondEntity and ThirdEntity.

If I use my subclasses for a "FetchEntityCollection" it always throws an error. "item can't be null"

What am I doing wrong?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 25-Jul-2014 15:18:16   

Chris187 wrote:

Hi,

I read on the forum that I cannot change the name of the entities and that I should use subclasses instead.

if you want to get rid of the 'entity' suffix. But it's not without problems however. The main thing is that you also need extra factory classes, and you're effectively creating a parallel hierarchy, which isn't recommended.

So I created a subclass for each entity:


    public class First : FirstEntity { }
    public class Second: SecondEntity { }
    public class Third : ThirdEntity { }

Now I want to use First, Second and Third in my code instead of FirstEntity, SecondEntity and ThirdEntity.

If I use my subclasses for a "FetchEntityCollection" it always throws an error. "item can't be null"

What am I doing wrong?

It's unfortunately not that simple. You also need to create additional factories, and e.g. Customer.Orders has to return a collection of Order instances, not OrderEntity instances.

Is having the 'Entity' suffix a problematic situation for you? Because it's more trouble than it's worth to get rid of it.

Frans Bouma | Lead developer LLBLGen Pro
Chris187
User
Posts: 6
Joined: 11-Jul-2014
# Posted on: 25-Jul-2014 17:30:41   

Yes, for now it is the only reason.

We have to refactor a lot of code if the entity names are changing and my intention was to save time.

But if you say it's not recommended I will have to spend this time simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 28-Jul-2014 14:25:06   

It's indeed not recommended to change it. Sorry for this inconvenience.

Frans Bouma | Lead developer LLBLGen Pro