使用实体框架处理 MDI 应用程序中的对象上下文

发布于 2024-12-26 03:15:54 字数 289 浏览 3 评论 0原文

我正在使用实体框架构建 MDI 应用程序,但我想知道如何在所有窗口中使用对象上下文。 我计划在应用程序中使用单个上下文(单例),但根据我的要求,我必须处理每个窗口的撤消更改(如果用户不想保存更改)。此外,一切都必须绑定,因此窗口中的更改必须更新另一个窗口中的相应对象。

由于我们可以有多个窗口,因此很难在上下文中看到哪个实体被哪个窗口修改,并在必要时撤消更改。 我认为我们可以为每个窗口创建一个本地上下文,但这样就很难维护(然后可能会将此本地上下文与全局上下文同步)。

您是否想过如何处理这种情况下的上下文?

谢谢。

I am building a MDI application using Entity Framework but I am wondering how to use the object context accross all the windows.
I planned to use a single context (singleton) accross the application but in my requirements, I must handle undo changes for each window (if the user does not want to save changes). Moreover, everything must be bound, so a change in a window must update the corresponding object in another window.

Since we can have multiple windows, it is difficult to see in the context which entity was modified by which window and undo changes if necessary.
I thought that we could create a local context for each window but then it would be difficult to maintain (and then maybe synchronize this local context with the global one).

Do you have any thought on how to handle the context in such case?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪意 2025-01-02 03:15:54

您的要求只是说您的窗口不能直接绑定到上下文。您必须让中间层执行应用程序逻辑,例如窗口数据同步和撤消,并且该层将与上下文通信以加载或保留数据。在您的情况下,该层可以称为 Presenter =>如果您有多种类型的操作,则单个演示者处理多个窗口的 MVP 模式+可能用于处理撤消的命令模式。

Your requirements simply say that your windows cannot be bound directly to context. You must have intermediary layer doing your application logic like window data synchronization and undo and this layer will communicate with context just to load or persist data. In your case the layer can be called presenter => MVP pattern with single presenter handling multiple windows + probably command pattern for handling undo if you have many types of operations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文