开发者

Copying persistent data across db sessions/units of work

开发者 https://www.devze.com 2022-12-23 06:33 出处:网络
I use DevExpress\' XPO ORM, but I suspect that this applies to many other ORMs and this happens to me all of the time and it\'s starting to get annoying.

I use DevExpress' XPO ORM, but I suspect that this applies to many other ORMs and this happens to me all of the time and it's starting to get annoying.

The situation is:

  • 1 form with a UnitOfWork used to populate user controls etc. with data from the db. (eg. a user settings form)
  • a dialog window with a UnitOfWork used to populate user controls. (eg. a permissions screen)

The resolutions that I can think of aren't ideal. Keep in mind that I can't copy objects across sessions/units of work in XPO (as far as I can tell).

  1. I don't want to just create the the persistent 开发者_运维知识库objects in the dialog and commit them with the dialog's unit of work, because then the user can't cancel out of the form without making changes (unless I went back to the DB and deleted the object persisted in the dialog)

  2. Forcing all of the dialogs in the software to take a reference to a unit of work in the constructor smells terrible.

  3. Having to re-create objects in the form that were created in the dialog smells terrible as well.

what else can I do?


This is a late answer, but may help others: The solution to your problem is to use a Nested Units of Work.

0

精彩评论

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

关注公众号