aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs
diff options
context:
space:
mode:
authorlbsa712008-01-15 10:15:39 +0000
committerlbsa712008-01-15 10:15:39 +0000
commit47c65295236560b0c58c1797ce2ad19418fa2b94 (patch)
tree1aacd2f02d5c6a585a9fc61e0b3c57ae6beaf1d9 /ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs
parent* Delinking doesn't leave invisible physical objects behind anymore (diff)
downloadopensim-SC-47c65295236560b0c58c1797ce2ad19418fa2b94.zip
opensim-SC-47c65295236560b0c58c1797ce2ad19418fa2b94.tar.gz
opensim-SC-47c65295236560b0c58c1797ce2ad19418fa2b94.tar.bz2
opensim-SC-47c65295236560b0c58c1797ce2ad19418fa2b94.tar.xz
* Some morw work on specializing the database framework for OpenSim
Diffstat (limited to '')
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs25
1 files changed, 15 insertions, 10 deletions
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