Specifying to use the Oracle Managed -vs- Unmanaged driver

Posts   
 
    
greenstone
User
Posts: 132
Joined: 20-Jun-2007
# Posted on: 09-Feb-2016 23:18:45   

LLBlGen 4.2 SD.LLBLGen.Pro.SQL.OracleODPNet.dll 4.2.14.903 9/3/2014 SD.LLBLGen.Pro.ORMSupportClasses.dll 4.2.14.903 9/3/2014 .NET 4.0 LLBLGen Adapter

When making a call to instantiate the DataAccessAdapter for Oracle, how does one specify to use the Oracle Managed driver or the Oracle Unmanaged driver?

For example, here's the call in my code for creating the adapter (but there appears to be no provider for specifying the provider-invariant-name)

SD.LLBLGen.Pro.ORMSupportClasses.IDataAccessAdapter adapter = new Grb.Platform.Framework.Business.Lower.Oracle.DatabaseSpecific.DataAccessAdapter(ConnectionString, true, null, null);

The concern is that I might have both the managed and unmanaged driver on my machine, and I want to specifically target one or the other.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 10-Feb-2016 16:36:50   
Frans Bouma | Lead developer LLBLGen Pro
greenstone
User
Posts: 132
Joined: 20-Jun-2007
# Posted on: 10-Feb-2016 17:05:02   

Thanks!

greenstone
User
Posts: 132
Joined: 20-Jun-2007
# Posted on: 12-Feb-2016 03:54:36   

We have customers running the application, and we would like to log if they are using the Oracle managed or the Oracle unmanaged driver. Is there a way we can find out (so we can put in our log file) which LLBLGen has decided to use (meaning to let us know if the customer has both managed and unmanaged on the machine and/or the special key llblgen looks at to force the llblgen to use the unmanaged driver)?

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 12-Feb-2016 17:44:44   

Do you want to force the Managed Provider?

Maybe this would help: Check this out (from http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=22508&HighLight=1): 1. The Oracle.ManagedDataAccess.dll should exist in the same directory as the code is executed from. (CopyLocal=true?) 2. TnsName.ora should also be in this folder. 3. Add the provider in your config.

greenstone
User
Posts: 132
Joined: 20-Jun-2007
# Posted on: 12-Feb-2016 17:56:16   

Thanks for the note...

Well, we found your post describing how to force to use the unmanaged driver: <add key="ODPNETAlwaysChooseUnmanagedProvider" value="false" /> So (assuming the unmanaged driver is installed), we would know llblgen is using the unmanaged driver (but I guess we'd need to write some code to figure out if the managed driver is installed).

The genesis of this question is, because we don't have access to the machines where our customers host the software, and this managed -vs- unmanaged driver can seemingly causes issues, we would really like to be able to log if llblgen (after the key over ride, it looking to see which are installed on the machine) decided to use...so we can put this in our log file (the customer can send us the log file...but they often don't know exactly what they have installed on their machines)

Is there a way we can ask llblgen which (managed or unmanaged) that it decided to use?

If not, might we be able to get a copy of the decision code llblgen uses, so we can run the same code--to replace the decision llblgen is doing (so we can log which llblgen is using)?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 13-Feb-2016 10:08:02   

It's not hard to check. We simply first try to get the DbProviderFactory for "Oracle.ManagedDataAccess.Client". You can do that using code like:

http://referencesource42.llblgen.com/#SD.LLBLGen.Pro.ORMSupportClasses/Persistence/DbProviderFactoryInfo.cs,cfa55cc81cc4b36c

If the managed client factory isn't there, it will try to obtain the unmanaged client factory using: "Oracle.DataAccess.Client"

So it comes down to simply obtain an instance of the DbProviderFactory for first the managed and then the unmanaged client.

If you want to know which factory is used by the DQE, you can ask the adapter:

var factoryUsed = new DataAccessAdapter().GetDbProviderFactoryInstance();

This will instantiate a DQE and obtain the factory. Factories are stateless static instances, so this takes no time. With the factory instance you can then check which assembly they're in, the managed or the unmanaged, and use that to determine if the managed or the unmanaged is used.

Frans Bouma | Lead developer LLBLGen Pro
greenstone
User
Posts: 132
Joined: 20-Jun-2007
# Posted on: 13-Feb-2016 14:12:33   

Thanks!