Hi there,
sorry if this is a stupid question but i'm not sure of the best way to handle this. I have a class which contains a collection and I also want a property that points to one of these as a default so ideally i would like:
class A
public Item Default { }
public IList<Item> items { }
the bit I am struggling with is how to set this up in the hbm file and in the class as its really just points to one of the items in the bag but it stores the key of the item that is the default. When I create a new instance of class A and I want to set a default item I am having to use a transaction so I save the item first, get its new key and then add it to the class and then save that out too and I wrap this in a transaction but I was wondering if there is a tidier way of doing this?
here's what I do to save a new instance of class A and have a default item:
GetITransaction { Create new Item Save it Create Class A and add the new item to its collection (new item has an id now we have saved it) Save Class A commit }
This works but is it the best way of doing this or am I missing something?
Thanks Andrew. }
|