BreezeJS-处理跨模块的查找表 [英] BreezeJS - handling lookup tables across modules

查看:65
本文介绍了BreezeJS-处理跨模块的查找表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个大型应用程序,允许用户在应用程序内的不同模块之间切换。每个模块都需要能够单独保存,因此每个模块都有自己的EntityManager。



不过,我们还是希望在整个应用程序中使用一些查找表。 。如果我们使用不同的EntityManager在应用程序级别加载查找表,则它们在模块中不是很有用。



例如,如果我想在应用程序级别加载国家查询表,那么我就不能做以下简单的事情:



Person.Country = lookupDataContext.getCountry('Norway')



如果Person在模块的EntityManager中。我将得到类似这样的信息:



一个实体不能附加到另一个EntityManager中的一个实体。必须首先分离两个实体之一。



我正确理解BreezeJS吗?如果是这样,是否意味着我需要在每个模块的EntityManager中进行国家/地区查询?

解决方案

我相信这个问题与 关于拥有多个 EntityManagers 的其他问题 。看看我在这里描述的一般想法。



更具体一点:




  • 微风实体无法导航到其他 EntityManager 中的相关实体;这就是错误消息告诉您的内容。

  • 您可能确实想要引用实体的单独实例(例如,国家/地区

  • 您可以使用导出导入方法。您不必回到服务器。



现在,而不是 lookupDataContext ,每个沙箱数据上下文都可以具有 sandboxContext.lookups.countries 方法,该方法从适当的沙箱管理器传递适当的实体。



这是限制吗?只要$ p


  • 您不会在管理人员之间复制大量数据,我就认为它没有那么糟糕。

  • 参考实体在用户会话期间基本上是不可变的。

  • 用户会话不会使太多沙盒管理器同时处于活动状态

  • 在您完成对沙箱管理器(及其数据上下文)的处理或处置后。



您应该能够实现从服务器加载一次查找并在主管理器中进行集中管理的目标。



这种方法在很大程度上已经非常成功过去十年中的应用程序数量(很明显是轻风之前)。



HTH。


We have a large application that allows the user to switch between different modules within the application. Each module needs to be able to save separately, so each module has it's own EntityManager.

There are some lookup tables, though, that we would like to use across the application. If we load the lookup tables at the application level, using a different EntityManager, they are not very usable then within the modules.

For example, if I want to load a 'Countries' lookup table at the application level, I then can't do something as simple as:

Person.Country = lookupDataContext.getCountry('Norway')

if Person is within a module's EntityManager. I will get something like:

"An Entity cannot be attached to an entity in another EntityManager. One of the two entities must be detached first."

Am I understanding BreezeJS correctly? If so, does that mean I need to have the Countries lookup within each module's EntityManager? This seems very limiting.

解决方案

I believe this question is related to your other question about having multiple EntityManagers. Check out my general thoughts there which cover the scenario you describe here.

To be slightly more specific:

  • Breeze entities cannot navigate to related entities in a different EntityManager; that's what the error message is telling you.
  • You probably do want separate instances of the reference entities (such as Countries) in both managers.
  • You can easily copy any set of entities from one manager to another with export and import methods. You don't have to go back to the server.

Now, instead of a lookupDataContext, each sandbox datacontext can have a sandboxContext.lookups.countries method that delivers the appropriate entities from the proper sandbox manager.

Is this limiting? I don't think it's so bad as long as

  • you aren't duplicating an enormous amount of data across managers.
  • the reference entities are essentially immutable during a user session.
  • a user session doesn't keep too many sandbox managers alive at the same time
  • you dispose of or re-cycle the sandbox managers (and their datacontexts) when you're done with them.

You should be able to achieve your goal of loading lookups from the server once and managing them centrally in the master manager.

This approach has been very successful in a great number of applications over the last decade (pre-Breeze obviously).

HTH.

这篇关于BreezeJS-处理跨模块的查找表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆