Thanks for your help marcal; I really appreciate your time.
Your right, I have stripped out a lot for demonstration. (hence the bag vs list) But I don't really have any buisness rules yet (i'm still setting up the database); I've been trying to get a handle on hibernate, and have been doing a lot of expermentation.
I can see my mistake with BranchID, but I'm going around and around. What I really want to do is simply remove an item from a collection. My needs seem quite similar to the example in section 19.3 so I followed that mapping.
Going back to that example. How would one say; remove a link to a product from the order, given the product id.
if one were to say
Code:
order.LineItems.Remove(lineItem);
How do I get a hold of the lineItem instance to remove.
I can iterate through the LineItems collection and check for
Code:
foreach (LineItem item in order.LineItems)
{
if (order.LineItems.Product.ID == id)
{
lineItem = item;
break;
}
}
order.LineItems.Remove(lineItem);
But I feel like I should be able to use the ORM to do this sort of thing, and query directly for the lineItem with a spacific product id. I'm I still missing something or is this the best way to get at the lineItem?