Permalink
Browse files

Added new constructor to DynamicModel using DbConnectionStringBuilder…

… instead of looking for configured connection string.
  • Loading branch information...
1 parent 8a514ee commit 2b12f3499844b826f88752d4d0b068072cfe2ae9 @DoggettCK committed Apr 3, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 Massive.cs
View
@@ -126,6 +126,21 @@ public class DynamicModel : DynamicObject {
_factory = DbProviderFactories.GetFactory(_providerName);
ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
}
+ protected DynamicModel(DbConnectionStringBuilder connectionStringBuilder, string tableName = "",
+ string primaryKeyField = "", string descriptorField = "")
+ {
+ TableName = tableName == "" ? this.GetType().Name : tableName;
+ PrimaryKeyField = string.IsNullOrEmpty(primaryKeyField) ? "ID" : primaryKeyField;
+ DescriptorField = descriptorField;
+
+ string _providerName =
+ connectionStringBuilder.ContainsKey("ProviderName")
+ ? (string) connectionStringBuilder["ProviderName"]
+ : "System.Data.SqlClient";
+
+ _factory = DbProviderFactories.GetFactory(_providerName);
+ ConnectionString = connectionStringBuilder.ConnectionString;
+ }
/// <summary>
/// Creates a new Expando from a Form POST - white listed against the columns in the DB

0 comments on commit 2b12f34

Please sign in to comment.