Browse files

Use provider specified in connection string.

Massive.Oracle.cs was hard coded to use System.Data.OracleClient as the DbProviderFactory. This change will keep that as a default unless a provider name is specified in the connection string entry.
  • Loading branch information...
1 parent 32b0dee commit 565350ae423966abd2e7adbb6d34022bdc5465a7 @jthope jthope committed Nov 21, 2012
Showing with 16 additions and 6 deletions.
  1. +16 −6 Massive.Oracle.cs
View
22 Massive.Oracle.cs
@@ -108,23 +108,33 @@ public class DynamicModel : DynamicObject {
string ConnectionString;
string _sequence;
- public static DynamicModel Open(string connectionStringName)
- {
+ public static DynamicModel Open(string connectionStringName) {
dynamic dm = new DynamicModel(connectionStringName);
return dm;
}
public DynamicModel(string connectionStringName, string tableName = "",
string primaryKeyField = "", string descriptorField = "", string sequence = "") {
+
TableName = tableName == "" ? this.GetType().Name : tableName;
PrimaryKeyField = string.IsNullOrEmpty(primaryKeyField) ? "ID" : primaryKeyField;
DescriptorField = descriptorField;
_sequence = sequence == "" ? ConfigurationManager.AppSettings["default_seq"] : sequence;
- _factory = DbProviderFactories.GetFactory("System.Data.OracleClient");
- if (ConfigurationManager.ConnectionStrings[connectionStringName] == null)
+
+ var _providerName = "System.Data.OracleClient";
+ var _connectionStringKey = ConfigurationManager.ConnectionStrings[connectionStringName];
+
+ if (_connectionStringKey == null) {
ConnectionString = connectionStringName;
- else
- ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
+ } else {
+ ConnectionString = _connectionStringKey.ConnectionString;
+ if (!string.IsNullOrEmpty(_connectionStringKey.ProviderName)) {
+ _providerName = _connectionStringKey.ProviderName;
+ }
+ }
+
+ _factory = DbProviderFactories.GetFactory(_providerName);
+
}
/// <summary>

0 comments on commit 565350a

Please sign in to comment.