开发者

NHibernate - Sequence numbers for child objects

开发者 https://www.devze.com 2023-02-20 11:48 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号