New Posts New Posts RSS Feed: IDataSourceKeyResolver example
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

IDataSourceKeyResolver example

 Post Reply Post Reply
Author
vecs View Drop Down
Newbie
Newbie


Joined: 05-Dec-2007
Location: Russian Federation
Posts: 22
Post Options Post Options   Quote vecs Quote  Post ReplyReply Direct Link To This Post Topic: IDataSourceKeyResolver example
    Posted: 24-Oct-2013 at 4:43am
I am thinking of use IDataSourceKeyResolver for dynamic Connection strings handling.
I got test solution from here:
http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-custom-datasourcekeyresolver
but it does not work.

I have the following situation:

* ServerModelTomato.Tomato entity have attribute:
[IbEm.DataSourceKeyName(@"Tomato")]

* Console01. Program execute this:

      var entityManager = new DomainModelEntityManager(true, "Customer01");
      foreach (var tomato in entityManager.Tomatoes) {
        Console.WriteLine("Tomato {0}", tomato.Variety);
      }


* During first call to entityManager.Tomatoes, CustomDataSourceKeyResolver.GetKey method invoked
and proper 'Tomato_Customer01' ClientEdmKey generated along with proper connection string.

* Then the error raised:
The connection string for Key 'Tomato_Customer01' was not found or is invalid.  Check that either a connectionStrings element or EdmKey is defined for this key in the configuration file, or implement a custom IDataSourceKeyResolver.

It seems that dynamically created ClientEdmKey was ignored or lost somewhere.

Is this a bug or I have missed something?


Edited by vecs - 24-Oct-2013 at 4:43am
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: 24-Oct-2013 at 10:27am
Did you unzip and install the databases in the data subfolder?   My guess is that the GetConnectionString logic is failing because it can't access the tenant database, as the sample works fine for me.
Back to Top
vecs View Drop Down
Newbie
Newbie


Joined: 05-Dec-2007
Location: Russian Federation
Posts: 22
Post Options Post Options   Quote vecs Quote  Post ReplyReply Direct Link To This Post Posted: 25-Oct-2013 at 1:07am
[Solved]

I forgot to try common trick against strange application behavior.

After computer reboot, application works as expected.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down