Obtain the Primary key name

Posts   
 
    
arjanv
User
Posts: 512
Joined: 15-Nov-2006
# Posted on: 29-Nov-2006 15:08:16   

Hi,

Is it possible to obtain the Primary key name of an entity in an lpt template. The Primary key is not included in the IEntityMapTargetElement.UniqueConstraints (logically).

t.i.a Arjan Vermunt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 29-Nov-2006 18:54:37   

What exactly do you mean with PK name? The fields which make up the PK?

IEntityMapTargetElement is the target an entity is mapped on. You miss fields if you look at that object, you should look at the EntityDefinition object. That object contains a PrimaryKeyFields collection.

In an entity which is in a hierarchy of TargetPerEntityHierarchy, the PK fields are defined in the ROOT of the hierarchy. All other entities (thus subtypes) have no pk fields defined, as these are in the supertype and inherited from the supertype. So test on that.

For the other situations (targetperentity and no inheritance) the pk fields are in that collection.

Frans Bouma | Lead developer LLBLGen Pro
arjanv
User
Posts: 512
Joined: 15-Nov-2006
# Posted on: 30-Nov-2006 09:03:03   

I mean the name of the Primary key in f.i. Oracle. This name also appears in the database exception when a duplicate record is trying to be added.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 30-Nov-2006 09:51:16   

So the PK fields of the table? As the unique constraint name for the PK isn't read from the db, just the PK fields. Most databases don't assign a name to the PK constraint.

Frans Bouma | Lead developer LLBLGen Pro