breeze - BreezeJS - handling lookup tables across modules -
we have large application allows user switch between different modules within application. each module needs able save separately, each module has it's own entitymanager.
there lookup tables, though, use across application. if load lookup tables @ application level, using different entitymanager, not usable within modules.
for example, if want load 'countries' lookup table @ application level, can't simple as:
person.country = lookupdatacontext.getcountry('norway')
if person within module's entitymanager. like:
"an entity cannot attached entity in entitymanager. 1 of 2 entities must detached first."
am understanding breezejs correctly? if so, mean need have countries lookup within each module's entitymanager? seems limiting.
i believe question related your other question having multiple entitymanagers. check out general thoughts there cover scenario describe here.
to more specific:
- breeze entities cannot navigate related entities in different
entitymanager; that's error message telling you. - you do want separate instances of reference entities (such countries) in both managers.
- you can copy set of entities 1 manager export , import methods. don't have go server.
now, instead of lookupdatacontext, each sandbox datacontext can have sandboxcontext.lookups.countries method delivers appropriate entities proper sandbox manager.
is limiting? don't think it's bad long as
- you aren't duplicating enormous amount of data across managers.
- the reference entities immutable during user session.
- a user session doesn't keep many sandbox managers alive @ same time
- you dispose of or re-cycle sandbox managers (and datacontexts) when you're done them.
you should able achieve goal of loading lookups server once , managing them centrally in master manager.
this approach has been successful in great number of applications on last decade (pre-breeze obviously).
hth.
Comments
Post a Comment