Copy an Entity

Posts   
 
    
DarkRoast
User
Posts: 42
Joined: 14-Jul-2010
# Posted on: 05-Aug-2011 20:42:34   

Hi All,

I'm trying to create a domain model by extending my generated entity classes or whatever the best way may be.

Let's say i have a table named Car and have a generated CarEntity in my code. I want to be able to create a SportsCarEntity class via inheritance. However, since constructors are not inherited, I can't just work with the SportsCarEntity in the same way as the CarEntity without re-writing the constructor logic.

It looks like inheritance won't work for me here, right?

So, I thought I could use the designer to map the Car table to an entity named SportsCarEntity.

That is fine, however, let's say I've renamed a bunch of fields in my CarEntity and I want to make sure all those field names are the mapped the same way in SportsCarEntity. What I really want to do is use the designer to copy the CarEntity as opposed to re-mapping and re-doing all the naming from the Car table.

I don't have a discriminator column in the table, so TargetPerEntityHierarchy won't help me either.

Is there another way to get distinctly named entity classes from a single table?

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Aug-2011 00:15:50   

So you don't have inheritance at DB. You just want to create another entity to specialize code. What really are you trying to achieve with this?

Anyway, You could just inherit the entity at code:

public class SportCartEntity : CarEntity
{
    // you code
}
David Elizondo | LLBLGen Support Team