Removing entities from an entity collection

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 03-Jul-2009 17:44:47   

Hi, is there a <built-in way> for removing some entities from an entity collection that matches a filter criteria?

say i have a UserCollection called users and i want to remove the users who are female from this collection. I know i can create a new collection with the given criteria and this is not what i want.

thanks -shane

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Jul-2009 20:34:31   

Hi Shane,

You could do something like:

List<int> entIndexesToRemove = users.FindMatches(UserFields.Female == true);
entIndexesToRemove.Reverse();
foreach (int i in entIndexesToRemove)
{
    users.RemoveAt(i);
}
David Elizondo | LLBLGen Support Team
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 06-Jul-2009 19:48:19   

daelmo wrote:

Hi Shane,

You could do something like:

List<int> entIndexesToRemove = users.FindMatches(UserFields.Female == true);
entIndexesToRemove.Reverse();
foreach (int i in entIndexesToRemove)
{
    users.RemoveAt(i);
}

Thank you David, i keep the users collection in the session object. and i use it for something. and i need the new (filtered) collection for some other reason. if i remove the females from the users collection, it gives me a problem in where i need the full list. if i dont remove it it gives me a problem in where i need the filtered list.

what would be the best thing to do here? i can keep a copy of users collection in session object with a different name and use one for full list and one for filtered list but i feel like theres gotta be a better way.

any suggestions? thanks -shane

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Jul-2009 05:36:04   

Hi Shine,

Ohh, I see now. You don't want to remove them, but create different versions of the view. You should use EntityViews. You can create different versions of the view, filtering on them, and the EntityCollection remains the same.

David Elizondo | LLBLGen Support Team
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 07-Jul-2009 08:57:01   

daelmo wrote:

Hi Shine,

Ohh, I see now. You don't want to remove them, but create different versions of the view. You should use EntityViews. You can create different versions of the view, filtering on them, and the EntityCollection remains the same.

thats exactly what i needed. thank you

-shane