Thanks for all the help markus. We're making some progress, but it
still doesn't work ...
Here's the relation:
[HasMany(typeof(EcoShoppingCartItem), ColumnKey = "ShoppingCartId",
Table = "EcoShoppingCartItems", Lazy = true, Cascade =
ManyRelationCascadeEnum.AllDeleteOrphan)]
Here's the deletion of item:
public virtual void DeleteItem(ItmItem item)
{
EcoShoppingCartItem foundItem =
GetShoppingCartItemIfItExists(item);
if (foundItem != null)
{
Items.Remove(foundItem);
}
}
Here's the Save:
ActiveRecordMediator<T>.Save(entity);
I can't update items in the IList<> or delete items from the IList but
I can add them all day long ... thanks again.
On Oct 28, 10:36 am, "Markus Zywitza" <[EMAIL PROTECTED]>
wrote:
> Another point:
>
> When you use SessionScope in the UT, you have to manually flush the scope
> before testing if someone changed in the DB. AutoFlush is currently broken
> due to NH2. I'm working on that but I'm kinda stuck there... :-(
>
> -Markus
>
> 2008/10/28 [EMAIL PROTECTED] <[EMAIL PROTECTED]>
>
>
>
> > I get an error that the belongsto is missing when I remove it.
>
> > Also tried that cascase type and the others. Still no luck.
>
> > I've also tried changing quantity on one of the items and persisting
> > and no luck.
>
> > Unit tests show the model is being update correctly. The changes are
> > not being persisted. Anyone have any ideas?
>
> > Thanks,
>
> > Kyle
>
> > On Oct 28, 3:13 am, "Markus Zywitza" <[EMAIL PROTECTED]> wrote:
> > > 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
-~----------~----~----~----~------~----~------~--~---