Fixed it. I ended up getting an old version where it worked fine from source control. Then I opened both the old and new projects and stripped every line down until I found the problem. I was actually adding the cart item to the items collection of the cart when I created an instance of a cart item. Somehow this single line of code has been lost. Anyway it's back now and all working fine.
On Tuesday, 13 January 2015 18:47:15 UTC, Lee Timmins wrote: > Thanks I have my cart items mapped like so (using Fluent NHibernate): > > HasMany(x => x.Items) > .Inverse() > .Cascade.Delete(); > > However this hasn't changed since I originally wrote it. I'm currently out > of ideas hence why I resorted to this post. I think i'm going to sleep on > it and see if I have any bright ideas. I'll post an update if I find a > solution. But feel free to throw any other ideas you think might be the > problem my way. Thanks > > On Tuesday, 13 January 2015 17:55:03 UTC, Ricardo Peres wrote: > >> ...and inverse=true on the Cart -> Items side! >> >> RP >> >> On Tuesday, January 13, 2015 at 4:32:24 PM UTC, Gustavo Ringel wrote: >>> >>> Where is your inverse definition? Make sure inverse=false on the cart >>> item which should be the owner of that association for that to work. >>> >>> Gustavo. >>> >>> On Tue, Jan 13, 2015 at 6:19 PM, Lee Timmins <[email protected]> >>> wrote: >>> >>>> Thanks, whilst this should work, it doesn't explain why it would be >>>> working before. >>>> >>>> >>>> On Tuesday, 13 January 2015 15:45:40 UTC, Ricardo Peres wrote: >>>>> >>>>> I think you need to call session.Refresh(cart). >>>>> >>>>> RP >>>>> >>>>> On Tuesday, January 13, 2015 at 3:12:09 PM UTC, Lee Timmins wrote: >>>>>> >>>>>> Say I have the following entities >>>>>> >>>>>> public class Cart { >>>>>> public virtual IList<CartItem> Items { get; set; } >>>>>> } >>>>>> >>>>>> public class CartItem { >>>>>> public virtual Cart Cart { get; set; } >>>>>> public virtual int Quantity { get; set; } >>>>>> } >>>>>> >>>>>> Now say I have the following code: >>>>>> >>>>>> var cart = GetCart(); // Returns a single Cart >>>>>> >>>>>> var cartItem = new CartItem() { Cart = cart, Quantity = 1 }; >>>>>> session.SaveOrUpdate(cartItem); >>>>>> >>>>>> session.Transaction.Commit(); >>>>>> >>>>>> var numItems = cart.Items.Count; >>>>>> >>>>>> The number of items doesn't include the newly added item. I know I >>>>>> could add it to the items collection on the cart but I have never had to >>>>>> do >>>>>> this in the past and I have noticed a lot of places where this is now >>>>>> broken. This is probably my fault for not including more unit tests but >>>>>> unfortunately I have no idea when I introduced this bug. I was wondering >>>>>> if >>>>>> anyone has any ideas why this would suddenly stop behaving like it did >>>>>> before. Please let me know if you require more information. >>>>>> >>>>>> I'd appreciate the help. Thanks >>>>>> >>>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "nhusers" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at http://groups.google.com/group/nhusers. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
