aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty
diff options
context:
space:
mode:
Diffstat (limited to 'ThirdParty')
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs9
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs25
2 files changed, 19 insertions, 15 deletions
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs
index 818c530..f2ee4f8 100644
--- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs
+++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs
@@ -32,8 +32,8 @@ namespace TribalMedia.Framework.Data
32{ 32{
33 public abstract class ObjectTableMapper<TRowMapper, TPrimaryKey> : TableMapper 33 public abstract class ObjectTableMapper<TRowMapper, TPrimaryKey> : TableMapper
34 { 34 {
35 public ObjectTableMapper(DatabaseMapper connectionPool, string tableName) 35 public ObjectTableMapper(DatabaseMapper database, string tableName)
36 : base(connectionPool, tableName) 36 : base(database, tableName)
37 { 37 {
38 } 38 }
39 39
@@ -52,7 +52,7 @@ namespace TribalMedia.Framework.Data
52 { 52 {
53 if (reader.Read()) 53 if (reader.Read())
54 { 54 {
55 result = FromReader(new DataReader(reader)); 55 result = FromReader( CreateReader(reader));
56 success = true; 56 success = true;
57 } 57 }
58 else 58 else
@@ -67,8 +67,7 @@ namespace TribalMedia.Framework.Data
67 67
68 return success; 68 return success;
69 } 69 }
70 70
71
72 public virtual bool Remove(TPrimaryKey id) 71 public virtual bool Remove(TPrimaryKey id)
73 { 72 {
74 int deleted = 0; 73 int deleted = 0;
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs
index 480a015..a2b0aa1 100644
--- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs
+++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs
@@ -33,14 +33,14 @@ namespace TribalMedia.Framework.Data
33{ 33{
34 public abstract class TableMapper 34 public abstract class TableMapper
35 { 35 {
36 private readonly DatabaseMapper m_connectionPool; 36 private readonly DatabaseMapper m_database;
37 private readonly object m_syncRoot = new object(); 37 private readonly object m_syncRoot = new object();
38 38
39 protected void WithConnection(Action<DbConnection> action) 39 protected void WithConnection(Action<DbConnection> action)
40 { 40 {
41 lock (m_syncRoot) 41 lock (m_syncRoot)
42 { 42 {
43 DbConnection m_connection = m_connectionPool.GetNewConnection(); 43 DbConnection m_connection = m_database.GetNewConnection();
44 44
45 if (m_connection.State != ConnectionState.Open) 45 if (m_connection.State != ConnectionState.Open)
46 { 46 {
@@ -74,40 +74,45 @@ namespace TribalMedia.Framework.Data
74 get { return m_keyFieldMapper; } 74 get { return m_keyFieldMapper; }
75 } 75 }
76 76
77 public TableMapper(DatabaseMapper connectionPool, string tableName) 77 public TableMapper(DatabaseMapper database, string tableName)
78 { 78 {
79 m_connectionPool = connectionPool; 79 m_database = database;
80 m_tableName = tableName.ToLower(); // Stupid MySQL hack. 80 m_tableName = tableName.ToLower(); // Stupid MySQL hack.
81 } 81 }
82 82
83 public string CreateParamName(string fieldName) 83 public string CreateParamName(string fieldName)
84 { 84 {
85 return m_connectionPool.CreateParamName(fieldName); 85 return m_database.CreateParamName(fieldName);
86 } 86 }
87 87
88 protected DbCommand CreateSelectCommand(DbConnection connection, string fieldName, object primaryKey) 88 protected DbCommand CreateSelectCommand(DbConnection connection, string fieldName, object primaryKey)
89 { 89 {
90 return m_connectionPool.CreateSelectCommand(this, connection, fieldName, primaryKey); 90 return m_database.CreateSelectCommand(this, connection, fieldName, primaryKey);
91 } 91 }
92 92
93 public string CreateCondition(DbCommand command, string fieldName, object key) 93 public string CreateCondition(DbCommand command, string fieldName, object key)
94 { 94 {
95 return m_connectionPool.CreateCondition(this, command, fieldName, key); 95 return m_database.CreateCondition(this, command, fieldName, key);
96 } 96 }
97 97
98 public DbCommand CreateInsertCommand(DbConnection connection, object obj) 98 public DbCommand CreateInsertCommand(DbConnection connection, object obj)
99 { 99 {
100 return m_connectionPool.CreateInsertCommand(this, connection, obj); 100 return m_database.CreateInsertCommand(this, connection, obj);
101 } 101 }
102 102
103 public DbCommand CreateUpdateCommand(DbConnection connection, object rowMapper, object primaryKey) 103 public DbCommand CreateUpdateCommand(DbConnection connection, object rowMapper, object primaryKey)
104 { 104 {
105 return m_connectionPool.CreateUpdateCommand(this, connection, rowMapper, primaryKey); 105 return m_database.CreateUpdateCommand(this, connection, rowMapper, primaryKey);
106 } 106 }
107 107
108 public object ConvertToDbType(object value) 108 public object ConvertToDbType(object value)
109 { 109 {
110 return m_connectionPool.ConvertToDbType(value); 110 return m_database.ConvertToDbType(value);
111 }
112
113 protected virtual DataReader CreateReader(IDataReader reader)
114 {
115 return new DataReader(reader);
111 } 116 }
112 } 117 }
113} \ No newline at end of file 118} \ No newline at end of file