开发者

NHibernate: SaveOrUpdate by <natural-id>

开发者 https://www.devze.com 2022-12-09 02:57 出处:网络
Is there an easy way to make NH INSERT or UPDATE an entity depending on whether there is already an enti开发者_StackOverflow中文版ty with same <natural-id />?

Is there an easy way to make NH INSERT or UPDATE an entity depending on whether there is already an enti开发者_StackOverflow中文版ty with same <natural-id />?

The entity is mapped to another (root) one using <many-to-one cascade="save-update" />.


Not automatically. You will have to read from the database to see if a record for that natural-id already exists and then determine if you need to do an insert or update. Which of course means that the cascade won't work.

I was looking for something similar in How do I Insert or Update (or overwrite) a record using NHibernate?

0

精彩评论

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