| Author |
Share Topic Topic Search Topic Options
|
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Topic: IDataSourceKeyResolver Posted: 30-Jul-2012 at 12:55am |
Hi,
We are implementing IDataSourceKeyResolver in our code to dynamically set our connection strings. All is working fine but we need a way to force the server to fire this IDataSourceKeyResolver again if we want to because currently, once the connection has been set, we will wait until it releases the connection used or alternatively by restarting the IIS.. We need a way to programmatically release the connection used by the EntityManager.
Thanks, Von
|
 |
mgood
IdeaBlade
Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
|
Post Options
Quote Reply
Posted: 30-Jul-2012 at 1:19pm |
I'm curious about what you are trying to do. IDataSourceKeyResolver is intended to let you externalize the connection strings instead of hard coding them in the web.config. It's not intended to dynamically change the connection strings to let the user connect to a different DB. The purpose of IDataSourceKeyResolver is so that you can move your code from your dev servers to the test servers to the production servers and have the connection information external to the code. Your connection strings will normally stay the same for each environment unless you move or rename servers. If you need the ability to dynamically connect to different DBs at runtime, you use the DataSourceExtension for that. Perhaps this thread over in the Cocktail forum applies to what you are trying to do.
Edited by mgood - 30-Jul-2012 at 1:24pm
|
 |
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Posted: 30-Jul-2012 at 7:43pm |
Consider the image below:
We have an administrative site where we configure the database connection, and we use the IDatasourceKeyResolver to get the details from the database of this site.
The problem is that when we changed the database connection in any case we need to, it will not get the latest connection because the IDatasourceKeyResolver is not firing anymore.
Now, we do not need to change the database connection while the application is running (we will force users to exit the application), what we need to do is a way to flush out the last connection and use the new one and we need a programmatic way to do that.
Btw, the actual application is a Windows Form application.
|
 |
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Posted: 30-Jul-2012 at 8:28pm |
To add on this, disregard the Tank Management Connection to avoid confusion..
Example in Global Connection, it points to a server instance of 192.168.0.31\Sql2005, database of iRelySuite.
If the administrator changed it to instance of 192.168.0.32\sql2005 or any other instance, we want to force the EntityServer to withdraw the last connection and change it to the new one.
Thanks, Von
|
 |
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 31-Jul-2012 at 9:38am |
Hi Von, Unfortunatelly, this is not a feature provided by DevForce at this time. (i.e. there's no way to way programmatically release the connection so to define a new one) Mgood's suggestion on using DataSourceExtension would be your best bet in this case. Kind regards, Silvio.
|
 |
Vonzkie
Senior Member
Joined: 01-Aug-2011
Location: PH
Posts: 133
|
Post Options
Quote Reply
Posted: 31-Jul-2012 at 8:47pm |
Hi Silvio,
But i believe that mgood's suggestion is static and our connection is dynamic based on the data on the database. I hope you can consider this, perhaps not by now but on your next release because we don't want to restart the IIS just to release the connection used.
Thanks, Von
|
 |
mgood
IdeaBlade
Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
|
Post Options
Quote Reply
Posted: 31-Jul-2012 at 9:09pm |
Yeah, the DataSourceExtension is not the way to go. Out of curiosity, how often does an admin change the connection string and why? It seems for such a low level configuration change a server restart is perfectly acceptable. You can appreciate that bad things will happen if you change the connection string without forcing all the clients to shut down and evict any data from the old database. In your environment it sounds like you take care of that, but not everybody can be trusted to do this.
Perhaps, you can call a server-side method that
programmatically restarts the app pool after changing of the configuration string.
|
 |
sbelini
IdeaBlade
Joined: 13-Aug-2010
Location: Oakland
Posts: 786
|
Post Options
Quote Reply
Posted: 01-Aug-2012 at 9:08am |
I was thinking about a set of predefined connections rather than new ones coming up dinamically. I'll add this to our feature request list. Silvio.
|
 |