...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] 
> <javascript:>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> 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.

Reply via email to