Reference an Enitity From an Entity Collection

Posts   
 
    
LloydM
User
Posts: 17
Joined: 05-Dec-2007
# Posted on: 18-Jan-2008 23:15:11   

I know I'm just missing something simple here.

I'm returning an index from the FindMatches method of an entity collection and now I want to get a specific entity from the collection using the index, but I seem unable to do soconfused

widgetIndex = widgetEntityCollection.FindMatches( new PredicateExpression(WidgetEntityFields.SomeId == 1));

How do I get a strongly typed reference to a widgetEntity in the widgetEntityCollection given an index?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Jan-2008 03:37:37   

Hi Lloyd,

FindMatches will return a List<int> of indexes... so, you need to do something like:

widgetIndex = widgetEntityCollection.FindMatches(WidgetEntityFields.SomeId == 1);

for (int i=0; i < widgetIndex.Length; i++)
{
     WidgetEntity oneMatch = widgetEntityCollection[ widgetIndex[i] ];
}
David Elizondo | LLBLGen Support Team
LloydM
User
Posts: 17
Joined: 05-Dec-2007
# Posted on: 21-Jan-2008 22:46:44   

David,

Your solution worked great! Thanks again for your help!