Custom database connection string and persistent context

Custom database connection string and persistent context

Old forum URL: forums.lhotka.net/forums/t/9077.aspx


chrisdot posted on Monday, June 14, 2010

Hi All,

I'm having a special request. I'm not a real .NET beginner, but I'm quite new to Web technologies like ASP, WCF and so on.

I've developped an additionnal web module to our main product. (using silverlight and of course CSLA) I didn't go into deep details regarding WCF and dataportal, as I'm not an expert. I just took the example given and built everything up on that, and it is doing what I planned.

But now, it is time to put this into production. So, here is my problem: I'm trying to get the DB connection settings in the main settings file of our main application. It is not a standard App.config nor Web.config (for various reasons), but a complex xml file that is editable with an external application to configure the whole product. And of course, the connection string is taken from that. We already have the library to extract the required data. My question is: where should I plug in that piece of code ? I don't want to call this piece of code each time I have to access data from the DB (fetch/update/etc...). Is there a way to get this value into a kind of persistent cache ? Basically my idea would be to have that code called once, at the first call to a  data request, but after it would be cached...

(I'm using EF4 as the DAL)

I had a look on WCF, because I suspect the answer to be in that area, like the attribute:

[ServiceBehavior(..InstanceContextMode = InstanceContextMode.Single)]

Do you have any ideas ?

Thank you,

Christophe

chrisdot replied on Tuesday, June 15, 2010

Is there no way to plug in a custom DB context retrieval on server side? (basically just to provide a custom located connection string)

I'm not sure about the vocabulary to be used, but what I'm trying to do, is just to provide a DB connection that I could reuse on each request, instead of having to get this configuration settings again.

If you have any idea, I'm just looking for leads.

Tanhk you,

Christophe

 

Copyright (c) Marimer LLC