NHibernate - Sequence numbers for child objects
In my business domain I need to do someth开发者_JAVA百科ing with n-th child object which is inserted for a given parent object. So for examples some business actions should be invoked after inserting 100th, 200th and 300th child.
For now I have an idea to add a number field for children so the first child (for a given parent object) gets 1, the second gets 2, ... and so on. How may it be achieved using NHibernate? Or maybe there are better ways to achieve my goals.
Thank you in advance for answers and ideas.
Best regards Lukasz
You can map your collection as a <list>
... so the index of the children is stored.
Then you can use an AddChild method to add elements, so you can execute custom logic when you reach the n-th child.
精彩评论