EntityCollection access by Key

Posts   
 
    
can1
User
Posts: 77
Joined: 16-Sep-2005
# Posted on: 20-Jan-2006 15:02:29   

I am using the adapter templates.

Does anyone know if there is a way to access entities in an EntityCollection by key, rather than just ordinal position in the items collection, kind of like a dictionary interface? So if the p-key of the entities in the collection are 343 and 456, I could use code like the following to access them directly: EntityCollection.Key[343], rather than having to loop through the set to find a specific entity?

Thanks,

Can1

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 21-Jan-2006 12:02:40   

CustomerEntity c = new CustomerEntity("CHOPS"); int index = myCustomers.IndexOf(c);

simple_smile

(though it will perform an O(n) loop till it finds the entity. It doesn't contain an index on pk, this is done because most of the time, you don't need the index, while it does take time to set it up. )

Frans Bouma | Lead developer LLBLGen Pro