Hi all,
Sorry if this is mentioned somewhere in the manual and I've missed it.
I have a CartEntity (represents a shopping cart) which has a collection 'CartDetailCollection'. CartDetailEntity is at the top of a TargetPerEntity hierarchy with two sub-types ProductDetailEntity and ContentDetailEntity.
When I load my CartEntity into memory (using prefetch paths to get the associated CartDetailCollection), I would like to be able to get collections of CartDetailEntities based on there type, for example, get all the ProductDetailEntities from my in-memory cart, without another call to the db.
The reason why I don't want to use 'Filtering on entity type' is because I am doing a lot of work to the CartEntity.CartDetailCollection in-memory so I want to avoid having to save the changes to the database and then re-fetch them using GetEntityTypeFilter() as this seems like an unneccessary call to the db.
Here's the method I'm using so far - Is there a better way?
public static CartDetailCollection GetContentItemsFromCart(CartEntity cart)
{
CartDetailCollection contentItems = new CartDetailCollection();
foreach (CartDetailEntity cartDetailEntity in cart.CartDetail)
{
if(cartDetailEntity is ContentDetailEntity)
{
contentItems.Add(cartDetailEntity);
}
}
return contentItems;
}
Thanks.