| Author |
Share Topic Topic Search Topic Options
|
jmarbutt
DevForce MVP
Joined: 04-Jun-2010
Posts: 17
|
Post Options
Quote Reply
Topic: Switching Connection String at Runtime Posted: 04-Jun-2010 at 11:08pm |
|
Ok this is just a simple question, but how do I switch the connection string at run time based on the user login?
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 07-Jun-2010 at 12:20pm |
|
In the Learning Resources, see the material on DataSourceKeys, DataSourceKeyResolvers, and DataSourceExtensions in the Business Object Persistence_Advanced topic document. There are also two Visual Studio solutions that address the topic, both in the folder Learning Resources\040_BusObjPersistence\DataSourceKeys.
Edited by GregD - 07-Jun-2010 at 12:21pm
|
 |
jmarbutt
DevForce MVP
Joined: 04-Jun-2010
Posts: 17
|
Post Options
Quote Reply
Posted: 08-Jun-2010 at 3:16pm |
|
Does this show how to do it only from the server side of the Silverlight application?
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 08-Jun-2010 at 5:41pm |
|
Tell me a bit more about what you're trying to do.
|
 |
jmarbutt
DevForce MVP
Joined: 04-Jun-2010
Posts: 17
|
Post Options
Quote Reply
Posted: 08-Jun-2010 at 7:12pm |
|
I am wanting to change the connection based on the authenticated user.
I am also trying to implement the custom authentication but haven't gotten that working yet either.
|
 |
DavidKozikowski
Groupie
Joined: 02-Feb-2010
Location: Aurora, IN
Posts: 59
|
Post Options
Quote Reply
Posted: 09-Jun-2010 at 6:12am |
Originally posted by GregD
In the Learning Resources, see the material on DataSourceKeys, DataSourceKeyResolvers, and DataSourceExtensions in the Business Object Persistence_Advanced topic document. There are also two Visual Studio solutions that address the topic, both in the folder Learning Resources\040_BusObjPersistence\DataSourceKeys.
|
The info in that section of documentation for DevForce 2010 states "Coming Soon!"
I do need some help / direction on what the App.Config file needs to look like when there are several databases involded. Can you provide a sample App.config file?
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 09-Jun-2010 at 5:45pm |
Originally posted by jmarbutt
I am wanting to change the connection based on the authenticated user. |
Sure, but I don't understand why you asked this question:
Originally posted by jmarbutt
Does this show how to do it only from the server side of the Silverlight application? |
The only place the connection string will be used is server-side.
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 09-Jun-2010 at 5:47pm |
Originally posted by DavidKozikowski
The info in that section of documentation for DevForce 2010 states "Coming Soon!" |
Maybe we just got it back in there for this release. I was looking at the docs going out with 6.0.3.
|
 |
jmarbutt
DevForce MVP
Joined: 04-Jun-2010
Posts: 17
|
Post Options
Quote Reply
Posted: 10-Jun-2010 at 10:23am |
|
I think my question around this is how does the EntityManager know how to use the CustomDataSourceKeyResolver? I don't see it assigned any where.
|
 |
jmarbutt
DevForce MVP
Joined: 04-Jun-2010
Posts: 17
|
Post Options
Quote Reply
Posted: 10-Jun-2010 at 10:30am |
|
Nevermind, I guess it is using reflection to do that, pretty cool, but could be better documented about that.
|
 |
kimj
IdeaBlade
Joined: 09-May-2007
Posts: 1391
|
Post Options
Quote Reply
Posted: 10-Jun-2010 at 11:01am |
You're right that we're still missing documentation on how DevForce probes for custom implementations. Briefly, we're using MEF (Managed Extensibility Framework) for most probing. When you implement a DevForce interface, or sub-type a base class, that type has been marked with the MEF InheritedExport attribute, which means that when a custom implementation is supplied MEF "should" find it. By default, in a .NET application that discovery will be in the exe/bin folder, and in Silverlight the XAP file.
As for what's used server-side vs. client side, or both, right now that's usually described in the API Reference Help. There's also more information in the Deployment chapter in the Learning Resources. In the case of the IDataSourceKeyResolver, although you can deploy your custom class to both client and server, it's only on the server that actual connection string resolution is required.
|
 |
jmarbutt
DevForce MVP
Joined: 04-Jun-2010
Posts: 17
|
Post Options
Quote Reply
Posted: 10-Jun-2010 at 11:34am |
|
Do you have any data in that sample app? It appears that I am not building my connection string correctly, I would like to compare what the connection string being past to the ClientEdmKey.
I think I just have something slightly off.
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 10-Jun-2010 at 4:01pm |
|
See the Data folder that accompanies the two DataSourceKey solutions. It contains two zips which contain a total of three databases: Tenant, Tomato01, and Tomato02. You need to attach those to your instance of SQL Server.
|
 |