Need some help with Delete multi or mulit many to many

Posts   
 
    
rtbike
User
Posts: 23
Joined: 23-Jan-2009
# Posted on: 07-Feb-2009 03:53:24   

Hello

I have two tables with a one to many relationship Cart and CartItems

I would like to delete a group of Items but I need to first get the UserId from the cart then delete only the items from that useres cart that are in a sertain shipping window which is called PreSeasonScheduleId.

I have tried Detete Mulit and DeleteMultiManytoOne but I am affraid I just don't understand how to make this work?

I am usind self servicing and using getMulti with the code below returns the correct data.

   CartItemCollection shipWindowItems = new CartItemCollection();
    RelationCollection cartRelation = new RelationCollection();
    cartRelation.Add(CartEntity.Relations.CartItemEntityUsingCartId);
    IPredicateExpression cartFilter = new PredicateExpression();
    cartFilter.Add(CartFields.UserId == UserID);
    cartFilter.AddWithAnd(CartItemFields.PreSeasonScheduleId ==  _PreSeasonScheduleId);
    shipWindowItems.DeleteMultiManyToOne();

Thanks for you help,

Todd

rtbike
User
Posts: 23
Joined: 23-Jan-2009
# Posted on: 07-Feb-2009 04:00:06   

Hello,

I figured it out, I needed to add the Args to the DeleteMulit----

CartItemCollection shipWindowItems = new CartItemCollection(); RelationCollection cartRelation = new RelationCollection(); cartRelation.Add(CartEntity.Relations.CartItemEntityUsingCartId); IPredicateExpression cartFilter = new PredicateExpression(); cartFilter.Add(CartFields.UserId == UserID); cartFilter.AddWithAnd(CartItemFields.PreSeasonScheduleId == _PreSeasonScheduleId); shipWindowItems.DeleteMulti(cartFilter, cartRelation);