Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added new constructor to DynamicModel using DbConnectionStringBuilder…

… instead of looking for configured connection string.
  • Loading branch information...
commit 2b12f3499844b826f88752d4d0b068072cfe2ae9 1 parent 8a514ee
@DoggettCK authored
Showing with 15 additions and 0 deletions.
  1. +15 −0 Massive.cs
View
15 Massive.cs
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.