New Posts New Posts RSS Feed: is there a way to get the connection string
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

is there a way to get the connection string

 Post Reply Post Reply
Author
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 Topic: is there a way to get the connection string
    Posted: 01-Jul-2009 at 8:10am
Back to the DataSourceResolver.  The GetDataSourceKey() function will load the key information if necessary.
 
   _entityManager.DataSourceResolver.GetDataSourceKey(typeof(Customer));
Back to Top
monkeyking View Drop Down
Groupie
Groupie
Avatar

Joined: 04-Mar-2009
Location: brisbane
Posts: 68
Post Options Post Options   Quote monkeyking Quote  Post ReplyReply Direct Link To This Post Posted: 01-Jul-2009 at 12:22am
one more question, can I detect which key is currently being used? i might have many keys, but only one DB has been connected, is there a way to detect that?
Back to Top
monkeyking View Drop Down
Groupie
Groupie
Avatar

Joined: 04-Mar-2009
Location: brisbane
Posts: 68
Post Options Post Options   Quote monkeyking Quote  Post ReplyReply Direct Link To This Post Posted: 01-Jul-2009 at 12:13am
thanks kimj, you are very helpful. 
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: 30-Jun-2009 at 7:12pm
EdmKeys is a public property on the IdeaBladeConfig class.  IdeaBladeConfig.Instance is the singleton instance of your loaded configuration information (from app.config or web.config).  This class is defined in IdeaBlade.Core, so you need an assembly reference to that, and a Using statement for the namespace. 
Back to Top
monkeyking View Drop Down
Groupie
Groupie
Avatar

Joined: 04-Mar-2009
Location: brisbane
Posts: 68
Post Options Post Options   Quote monkeyking Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jun-2009 at 5:54pm
hi kimj, sorry, i don't have an Edmkeys property in my IdeaBladeConfig.Instance, should I do sth first to make it appear?
Back to Top
monkeyking View Drop Down
Groupie
Groupie
Avatar

Joined: 04-Mar-2009
Location: brisbane
Posts: 68
Post Options Post Options   Quote monkeyking Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jun-2009 at 5:03pm
thanks kimj, you are very helpful. 
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: 30-Jun-2009 at 10:39am
The DataSourceResolver, although a public type, is primarily intended for internal use.  The DataSourceKeyNames (and DataSourceKeys, along with several other properties) are only loaded after several other trigger events. 
 
The best thing to use to look at connection strings in the IdeaBladeConfig.EdmKeys collection, like this:
 
      foreach (var key in IdeaBladeConfig.Instance.EdmKeys) {
        Debug.WriteLine(key.Name + ": " + key.Connection);
      }
If you omit the connection information from your client-side EdmKeys in an n-tier configuration (as you should), then the connection information is available only from server-side code.
Back to Top
monkeyking View Drop Down
Groupie
Groupie
Avatar

Joined: 04-Mar-2009
Location: brisbane
Posts: 68
Post Options Post Options   Quote monkeyking Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jun-2009 at 12:31am
            int count = 0;
            var query = AdditionalFunctions.manager.DataSourceResolver.DataSourceKeyNames;
           
            foreach (string s in query)
            {
                count++;
            }
            MessageBox.Show(count.ToString());

I wrote these code, but the message box says '0'. I'm not sure if i'm doing correct way.
Back to Top
monkeyking View Drop Down
Groupie
Groupie
Avatar

Joined: 04-Mar-2009
Location: brisbane
Posts: 68
Post Options Post Options   Quote monkeyking Quote  Post ReplyReply Direct Link To This Post Posted: 29-Jun-2009 at 11:57pm
I want to get the connection string
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down