Print Page | Close Window

OData and Using IDataSourceKeyResolver

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3226
Printed Date: 26-Mar-2025 at 5:45am


Topic: OData and Using IDataSourceKeyResolver
Posted By: markfinch
Subject: OData and Using IDataSourceKeyResolver
Date 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
 
 



Replies:
Posted By: kimj
Date 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.
 


Posted By: markfinch
Date 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



Print Page | Close Window