New Posts New Posts RSS Feed: OData and Using IDataSourceKeyResolver
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

OData and Using IDataSourceKeyResolver

 Post Reply Post Reply
Author
markfinch View Drop Down
Newbie
Newbie


Joined: 21-Jan-2012
Location: Sheffield UK
Posts: 5
Post Options Post Options   Quote markfinch Quote  Post ReplyReply Direct Link To This Post Topic: OData and Using IDataSourceKeyResolver
    Posted: 21-Jan-2012 at 7:22am
Hi All,
 
I am currently in the process of extending my Silverlight application (which uses Devforce) to also include a simplifed HTML5/JQuery version. I noticed that it is quite simple to enable OData on the server side which I did and tested working fine, but now I have hit a problem which I do not know how to solve.
 
At the minute the silverlight app authenticates and after authentication uses a key specific to the user to identify what database to connect to. This key is passed into Devforce (as a KeyExtension) when creating the datasource which is used on the server side in a custom IDataSourceKeyResolver.
 
I already know that the IDataSourceKeyResolver is being called when querying the OData feed but the keyExtnesion is blank. The problem I have is how to pass this key into the OData feed so that the keyExtension is specified.
 
 
Any help would be greatly appreciated
 
Thanks in advance
 
Mark
 
 
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-Jan-2012 at 11:06am
DevForce uses the data source key extension passed into an EntityManager.  That information is actually carried from client to server, and when the IDataSourceKeyResolver is called the extension originally set in the EM is what's used.
 
In OData, since we don't have any control over the client, you'll need to pass the extension into the EntityManager used by the OData service.  You can do this by overriding the CreateDataSource method in the OData service, so that you can then construct your EntityManager with the appropriate extension.  As for knowing that extension, you might pass it with the request, or retrieve it from a previously saved session variable.
 
Back to Top
markfinch View Drop Down
Newbie
Newbie


Joined: 21-Jan-2012
Location: Sheffield UK
Posts: 5
Post Options Post Options   Quote markfinch Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jan-2012 at 1:56am
Hi, Thanks for the reply...
 
In the end i took your advice and used session variables to store the key to pass to the entity manager in createdatasource. I added a layer of basic authentication to the odata feed which enabled me to catch the user logging in/requesting a page and using their credentials found the appropriate key for their database and stored it in a session variable. When the datasource was created I queried the session variables, got the key and set the datasource. Super!!
 
Thanks for your help
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down