New Posts New Posts RSS Feed: DataSourceKeyMap is too persistent
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

DataSourceKeyMap is too persistent

 Post Reply Post Reply
Author
MVenhola View Drop Down
Newbie
Newbie


Joined: 20-Sep-2010
Posts: 8
Post Options Post Options   Quote MVenhola Quote  Post ReplyReply Direct Link To This Post Topic: DataSourceKeyMap is too persistent
    Posted: 22-Nov-2011 at 7:55am
The DataSourceKeyMap dictionary in the DataSourceResolver object is a static property!  This is causing some real headaches. 
We've implemented a custom login screen with a server selection option.  After logging in our KeyResolver picks up our keys based on the server selection.
 
User logs out and the forms authentication login screen comes up as expected.
 
User logs in again, selecting a different server.  However, because the DataSourceKeyMap is static (and apparently, not clearable... we tried EntityManager.DataSourceResolver.DataSourceKeyMap.Clear(), didn't work), the only way the keys are reset is by closing the browser (ie, shutting down the app).
 
Shouldn't there be a way to reset the keys?
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 22-Nov-2011 at 5:35pm
Hi MVenhola;

Currently, there isn't a way to reset the keys.

However, your use case seems like a perfect example to use DataSourceExtension. Basically you pass in your DataSourceExtension when you create your EntityManager, and in your IDataSourceKeyResolver.GetKey method, you just resolve different keys based on the extension passed in.


Hope this helps.


Edited by DenisK - 22-Nov-2011 at 5:39pm
Back to Top
MVenhola View Drop Down
Newbie
Newbie


Joined: 20-Sep-2010
Posts: 8
Post Options Post Options   Quote MVenhola Quote  Post ReplyReply Direct Link To This Post Posted: 23-Nov-2011 at 6:55am
But it doesn't help.
 
The environment is selected on the server side during the login process.  Silverlight app is initialized after this.  The extension key wouldn't be known when the EntityManager is created on the client side.  It's a catch 22.
 
Hence the need to be able to clear the map.
Back to Top
MVenhola View Drop Down
Newbie
Newbie


Joined: 20-Sep-2010
Posts: 8
Post Options Post Options   Quote MVenhola Quote  Post ReplyReply Direct Link To This Post Posted: 23-Nov-2011 at 7:11am
Nevermind. Solution was simple.
When creating the entity manager on the client side, I pass a Guid.NewGuid().ToString("N") as the extension key, forcing each silverlight app to have it's own key values in the map.
 
Works as expected now.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 23-Nov-2011 at 9:55am
When you use a dynamic key extension like this you'll effectively have one EntityServer per Silverlight client, which in the long run is probably not what you want.  DevForce will create one EntityServer per key extension, but this usually translates into many clients with that key extension communicating with the one EntityServer dedicated to them. 
 
Since your login process is not part of the Silverlight application, you might be able to use initParams to pass the server information to the SL application, which in turn would use this as its key extension when creating an EntityManager. 
 
If initParams won't work, then maybe use one extension-less EntityManager to ask (maybe via an RPC call) which server it should be using for the user, and then create an EntityManager with a key extension representing that server.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down