Try with

Cascade = ManyRelationCascadeEnum.AllDeleteOrphan

And consider removing the BelongsTo completely. There is normally no need to
navigate from Item to ShoppingCart.

Here is my mapping for a similar model:

 [ActiveRecord]
 public class ShoppingCart
 {
  private Guid id;
  private string customer;
  private IList<CartItem> addresses = new List<CartItem>();
  [PrimaryKey(PrimaryKeyType.GuidComb, Access =
PropertyAccess.NosetterCamelcase)]
  public Guid Id
  {
   get { return id; }
  }
  [Property]
  public string Customer
  {
   get { return customer; }
   set { customer = value; }
  }
  [HasMany(typeof(CartItem),
   RelationType = RelationType.List, Index = "pos",
   Access = PropertyAccess.NosetterCamelcase,
   Cascade = ManyRelationCascadeEnum.AllDeleteOrphan, ColumnKey = "cart",
Table = "items")]
  public IList<CartItem> Addresses
  {
   get { return addresses; }
  }
 }

 [ActiveRecord("items")]
 public class CartItem
 {
  private Guid id;
  private string desc;
  [PrimaryKey(PrimaryKeyType.GuidComb, Access =
PropertyAccess.NosetterCamelcase)]
  public Guid Id
  {
   get { return id; }
  }
  [Property(NotNull = true)]
  public string Desc
  {
   get { return desc; }
   set { desc = value; }
  }
 }

-Markus

2008/10/28 [EMAIL PROTECTED] <[EMAIL PROTECTED]>

>
> I have a shopping cart object, it hasmany shoppingcartitems. pretty
> simple.
>
> On the cart object I have RemoveItem .. it looks like this:
>
> Items.Remove(foundItem);
>
> Then I save the cart (ActiveRecordMediator) hoping the shopping cart
> item will be affected an no beans.
>
> here's the relevant mapping(s):
>
> [BelongsTo("ShoppingCartId", Type = typeof(ShoppingCart), NotNull =
> true, Cascade = CascadeEnum.All), ValidateNonEmpty]
>
> [HasMany(typeof(ShoppingCartItem), ColumnKey = "ShoppingCartId", Lazy
> = true, Cascade = ManyRelationCascadeEnum.All)]
>
> Thanks for any/all help. I'm beating my head against the wall on this
> one.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to