private static DbProviderFactory GetDbProviderFactory(string providerName) { DbProviderFactory dbProviderFactory; if (!string.IsNullOrEmpty(providerName)) { // // If the user has supplied a provider name, that's the one // we must use. // dbProviderFactory = DbProviderFactoryQuery.GetFactory(providerName); } else { // // Otherwise, we try to use ODP.Net in the first instance // and then fallback to the Microsoft client. // dbProviderFactory = DbProviderFactoryQuery.FindFactory("Oracle.DataAccess.Client") ?? DbProviderFactoryQuery.GetFactory("System.Data.OracleClient"); } return(dbProviderFactory); }
public void InitializationDefaultsToOracleThenMicrosoftProvider() { var lookups = new Queue <string>(2); using (DbProviderFactoryQuery.PushGetFactoryHandler(next => (sender, name) => { lookups.Enqueue(name); throw new ArgumentException(); })) { Assert.Throws <ArgumentException>(() => new OracleErrorLog("...")); Assert.Equal(2, lookups.Count); Assert.Equal("Oracle.DataAccess.Client", lookups.Dequeue()); Assert.Equal("System.Data.OracleClient", lookups.Dequeue()); var config = new Dictionary <string, string> { { "connectionString", "..." }, }; Assert.Throws <ArgumentException>(() => new OracleErrorLog(config)); Assert.Equal(2, lookups.Count); Assert.Equal("Oracle.DataAccess.Client", lookups.Dequeue()); Assert.Equal("System.Data.OracleClient", lookups.Dequeue()); } }
private static DbProviderFactory GetDbProviderFactory(string providerName) { DbProviderFactory dbProviderFactory; if (!string.IsNullOrEmpty(providerName)) { // // If the user has supplied a provider name, that's the one // we must use. // dbProviderFactory = DbProviderFactoryQuery.GetFactory(providerName); } else { // // Otherwise, we fallback to the Microsoft client. // dbProviderFactory = DbProviderFactoryQuery.GetFactory("System.Data.OracleClient"); } return(dbProviderFactory); }