New Posts New Posts RSS Feed: Clear ClientEdmKey
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Clear ClientEdmKey

 Post Reply Post Reply
Author
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Topic: Clear ClientEdmKey
    Posted: 22-Aug-2011 at 1:06am
Hi,

I have implemented IDataSourceKeyResolver in my Project to handle dynamic connections.
However, it seems that there's some cacheing or storing of value going on here and the next time I initialize the same EntityManager with the same extension, the GetKey method is not firing anymore.

How can I clear the values that might probably stored somewhere, I want the GetKey to be fired every time I initialize  an EntityManager.

Thanks,
Von 
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2011 at 12:36pm
Hi Von;

The DataSourceKey caching is actually done on purpose for this very reason that the GetKey is not fired everytime if the extension has been resolved. And unfortunately, it seems that the caching is not accessible publicly. Before I give you a workaround, could you explain your use case for this?
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 24-Aug-2011 at 12:44am
Hi,

Because I'm validating the assembly that initiates the initialization of the EntityManager.
Only selected assembly should have the right to access the Model, basically for Layering and Security purposes only.

Thanks,
Von
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 24-Aug-2011 at 1:14am
Hi,

Another, since I'm trying to have a dynamic connection to the database (though it doesn't make sense to an n-tier environment), assuming I have a datasourceextension w/c was resolved already but I want to change the underlying connection string. E.g. if SampleExtension has a connection to VON\SQL2008R2 but i want to change it to VON2\SQL2008R2, how can i do that without defining another the datasourceextension?

Thanks,
Von 
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 24-Aug-2011 at 12:34pm
Because I'm validating the assembly that initiates the initialization of the EntityManager.
Only selected assembly should have the right to access the Model, basically for Layering and Security purposes only.

Is it possible for you to only initialize the EntityManager on those selected assemblies? This is so only selected assembly can access the Model and you never have to worry about validating the assembly.

Another, since I'm trying to have a dynamic connection to the database (though it doesn't make sense to an n-tier environment), assuming I have a datasourceextension w/c was resolved already but I want to change the underlying connection string. E.g. if SampleExtension has a connection to VON\SQL2008R2 but i want to change it to VON2\SQL2008R2, how can i do that without defining another the datasourceextension?

Do you mean that you want to change the SampleExtension's connectionString during runtime? If so, I don't believe this is possible. It wouldn't be a good idea either. You have to define another DataSourceExtension or change that SampleExtension's connectionString to point to VON2\SQL2008R2.
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 24-Aug-2011 at 6:52pm
Is it possible for you to only initialize the EntityManager on those selected assemblies? This is so only selected assembly can access the Model and you never have to worry about validating the assembly.

- What I'm doing is that I have a class project and a static function that validates the calling assemble and returns an instance of an EntityManager.

E.g. from the calling assembly:

 NorthwindIBEntities context = MyClass.GetNorthwindEntities();

Now, inside my GetNorthwindEntities function, I'm validating the calling assembly, and if it is permitted to have a connection to the database, It will return an instance of the EntityManager with the "Correct" datasourceextension and the calling assembly will have a connection to the database otherwise it can't connect to the database because it doesn't have the correct datasourceextension. 

Do you mean that you want to change the SampleExtension's connectionString during runtime? If so, I don't believe this is possible. It wouldn't be a good idea either. You have to define another DataSourceExtension or change that SampleExtension's connectionString to point to VON2\SQL2008R2.

How can I do the underlined statement in runtime when it is already resolved? Another, what's the drawback of using multiple dynamic datasourceextension? I mean, how about defining different datasourceextension during Application startup? The idea here is to let the user choose his/her server and database to connect to.. Btw., I'm talking about a Windows Form Application in a LAN environment






Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 25-Aug-2011 at 12:14pm
I'm validating the calling assembly, and if it is permitted to have a connection to the database, It will return an instance of the EntityManager with the "Correct" datasourceextension and the calling assembly will have a connection to the database otherwise it can't connect to the database because it doesn't have the correct datasourceextension.

I'm trying to follow what you're thinking here. If the calling assembly is valid, you will return an EntityManager with the correct extension and all is good. If the calling assembly is invalid, you can have 2 options:

1. Return null in which case, the calling assembly has to handle the logic.

or

2. Return an EntityManager with an invalid DataSourceExtension, in which case, the GetKey method should handle the logic by throwing an exception when a bad extension is encountered.

Does this sound about right?

change that SampleExtension's connectionString to point to VON2\SQL2008R2.

How can I do the underlined statement in runtime when it is already resolved?

You can't. Sorry for not being clear on this. I was actually suggesting changing the connectionString before runtime in your tenant database, or your config file or wherever you're storing this information.

how about defining different datasourceextension during Application startup? The idea here is to let the user choose his/her server and database to connect to

It is actually best practice to define multiple DataSourceExtension before runtime, for example in a tenant database or in your config file.


or

2. By defining EdmKey or multiple connectionStrings in your config file - http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-data-source-extensions

If you'd like to define your DataSourceExtension programatically during Application start up, you can do so by accessing the IdeaBladeConfig.Instance. Please see http://drc.ideablade.com/xwiki/bin/view/Documentation/configure-programmatically#HSpecifyingdatabaseconnectionsincode for more details.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down