Attaching a disconnected object to an NHibernate session; best practice?

后端 未结 1 1697
猫巷女王i
猫巷女王i 2021-01-01 21:24

My repository works in a UnitOfWork model; all operations, whether retrieval or persistence, must be performed within the scope of an IDisposable <

相关标签:
1条回答
  • 2021-01-01 21:49

    D: None of the above. Effectively disabling lazy-loading by keeping your UOW too short and defeats the purpose of a lazy-loading ORM. The fact that you have to re-associate disconnected objects as normal operations means that your unit of work boundaries are wrong.

    Merge, Update, and Lock all have different purposes. If you're stuck with your current architecture then Lock is probably what you want.

    • Update - associates a changed object
    • Lock - associates an unchanged object
    • Merge - if the object exists in the current session then it is updated with changes from the merged object, otherwise it's the same as Lock
    0 讨论(0)
提交回复
热议问题