Fast dynamic access to Primary Keys

Posts   
 
    
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 28-Nov-2008 16:55:33   

Right now I'm using reflection on the [Object]Fields class and enumerating the properties to find the primary key columns. Is there a faster way that can just return me which properties are the primary key ones?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Nov-2008 22:25:27   

Hi happyfirst simple_smile

Here is the easier way:

// given some customer
CustomerEntity someCustomer = new CustomerEntity();

// gets primary key fields
List<IEntityField2> pkFields = ((IEntity2)someCustomer).PrimaryKeyFields;

Hope helpful

David Elizondo | LLBLGen Support Team
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 02-Dec-2008 16:50:35   

Thanks! Although I had to use IEntity. IEntity2 was invalid cast.