Permalink
Browse files

Added the setting of the PrimaryKeyField default to the constructor, …

…removing need for getter logic
  • Loading branch information...
1 parent 2bfcb20 commit 23f2b03750f70337369c7e4cefb35366f125685d @subsonic subsonic committed Feb 19, 2011
Showing with 2 additions and 9 deletions.
  1. +2 −9 Massive.cs
View
11 Massive.cs
@@ -10,7 +10,6 @@
using System.Collections;
namespace Massive {
-
public static class ObjectExtensions {
/// <summary>
/// Extension method for adding in a bunch of parameters
@@ -59,7 +58,6 @@ public static class ObjectExtensions {
}
return result;
}
-
/// <summary>
/// Turns the object into an ExpandoObject
/// </summary>
@@ -94,7 +92,7 @@ public class DynamicModel {
public DynamicModel(string connectionStringName= "", string tableName = "", string primaryKeyField ="") {
TableName = tableName == "" ? this.GetType().Name : tableName;
- PrimaryKeyField = primaryKeyField;
+ PrimaryKeyField = string.IsNullOrEmpty(primaryKeyField) ? "ID" : primaryKeyField;
if (connectionStringName == "")
connectionStringName = ConfigurationManager.ConnectionStrings[0].Name;
var _providerName = "System.Data.SqlClient";
@@ -190,7 +188,6 @@ public class DynamicModel {
var commands = BuildCommands(things);
return Execute(commands);
}
-
public int Execute(DbCommand command) {
return Execute(new DbCommand[] { command });
}
@@ -211,11 +208,7 @@ public class DynamicModel {
}
return result;
}
- string _primaryKeyField;
- public string PrimaryKeyField {
- get { return string.IsNullOrEmpty(_primaryKeyField) ? /*a bit of convention here*/ "ID" : /*oh well - did our best*/ _primaryKeyField; }
- set { _primaryKeyField = value; }
- }
+ public string PrimaryKeyField { get; set; }
/// <summary>
/// Conventionally introspects the object passed in for a field that
/// looks like a PK. If you've named your PrimaryKeyField, this becomes easy

0 comments on commit 23f2b03

Please sign in to comment.