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.
1. Using tenant db - http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-custom-datasourcekeyresolver - http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-custom-datasourcekeyresolver
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 - 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 - http://drc.ideablade.com/xwiki/bin/view/Documentation/configure-programmatically#HSpecifyingdatabaseconnectionsincode for more details.
|