Mercurial > hg > ucis.core
annotate Database.cs @ 111:df53bdd49507 default tip
Merge
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Fri, 07 Nov 2014 18:37:39 +0100 |
parents | 40715b34d0d3 |
children |
rev | line source |
---|---|
0 | 1 ???using System; |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
2 using System.Collections.Generic; |
0 | 3 using System.Data; |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
4 using System.Reflection; |
0 | 5 |
6 namespace UCIS { | |
7 public class Database { | |
8 private delegate object ConstructorDelegate(); | |
9 private ConstructorInfo _ConnectionConstructor; | |
10 | |
11 public Database(Type DBConnectionType, string connectionString) { | |
12 this.ConnectionString = connectionString; | |
13 _ConnectionConstructor = DBConnectionType.GetConstructor(new Type[] { }); | |
14 } | |
15 | |
16 public string ConnectionString { get; set; } | |
17 | |
18 public virtual IDbConnection GetConnection() { | |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
19 IDbConnection conn = (IDbConnection)_ConnectionConstructor.Invoke(null); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
20 conn.ConnectionString = ConnectionString; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
21 conn.Open(); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
22 return conn; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
23 } |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
24 |
85
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
25 private static IDbCommand PrepareQuery(IDbConnection Connection, string Query, params object[] Parameters) { |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
26 IDbCommand Command = Connection.CreateCommand(); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
27 Command.CommandType = CommandType.Text; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
28 Command.CommandText = Query; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
29 Command.Parameters.Clear(); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
30 int ParameterI = 0; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
31 foreach (object Parameter in Parameters) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
32 IDbDataParameter DBParameter = Command.CreateParameter(); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
33 DBParameter.Direction = ParameterDirection.Input; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
34 DBParameter.ParameterName = "?" + ParameterI.ToString(); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
35 DBParameter.Value = Parameter; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
36 Command.Parameters.Add(DBParameter); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
37 ParameterI++; |
0 | 38 } |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
39 if (ParameterI > 0) Command.Prepare(); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
40 return Command; |
0 | 41 } |
42 | |
43 public IDbCommand PrepareQuery(string Query, params object[] Parameters) { | |
44 IDbConnection Connection = GetConnection(); | |
45 try { | |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
46 return PrepareQuery(Connection, Query, Parameters); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
47 } catch (Exception) { |
0 | 48 Connection.Close(); |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
49 throw; |
0 | 50 } |
51 } | |
52 | |
53 public int NonQuery(string QueryString, params object[] Parameters) { | |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
54 using (IDbConnection connection = GetConnection()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
55 using (IDbCommand command = PrepareQuery(connection, QueryString, Parameters)) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
56 return command.ExecuteNonQuery(); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
57 } |
0 | 58 } |
59 } | |
60 | |
61 public object FetchField(string QueryString, params object[] Parameters) { | |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
62 using (IDbConnection connection = GetConnection()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
63 using (IDbCommand command = PrepareQuery(connection, QueryString, Parameters)) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
64 return command.ExecuteScalar(); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
65 } |
0 | 66 } |
67 } | |
68 public object[] FetchRow(string QueryString, params object[] Parameters) { | |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
69 using (IDbConnection connection = GetConnection()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
70 using (IDbCommand command = PrepareQuery(connection, QueryString, Parameters)) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
71 using (IDataReader Reader = command.ExecuteReader()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
72 if (!Reader.Read()) return null; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
73 object[] Result = new object[Reader.FieldCount]; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
74 Reader.GetValues(Result); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
75 return Result; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
76 } |
0 | 77 } |
78 } | |
79 } | |
80 public object[][] FetchRows(string QueryString, params object[] Parameters) { | |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
81 using (IDbConnection connection = GetConnection()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
82 using (IDbCommand command = PrepareQuery(connection, QueryString, Parameters)) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
83 using (IDataReader Reader = command.ExecuteReader()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
84 List<object[]> Result = new List<object[]>(); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
85 while (Reader.Read()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
86 object[] ResultArray = new object[Reader.FieldCount]; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
87 Reader.GetValues(ResultArray); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
88 Result.Add(ResultArray); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
89 } |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
90 return Result.ToArray(); |
0 | 91 } |
92 } | |
93 } | |
94 } | |
95 public void ForEachRow(Action<Object[]> f, string QueryString, params object[] Parameters) { | |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
96 using (IDbConnection connection = GetConnection()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
97 using (IDbCommand command = PrepareQuery(connection, QueryString, Parameters)) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
98 using (IDataReader Reader = command.ExecuteReader()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
99 while (Reader.Read()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
100 object[] ResultArray = new object[Reader.FieldCount]; |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
101 Reader.GetValues(ResultArray); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
102 f(ResultArray); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
103 } |
0 | 104 } |
105 } | |
106 } | |
7
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
107 } |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
108 public void ForEachRow(Action<IDataRecord> callback, string query, params object[] parameters) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
109 using (IDbConnection connection = GetConnection()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
110 using (IDbCommand command = PrepareQuery(connection, query, parameters)) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
111 using (IDataReader Reader = command.ExecuteReader()) { |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
112 while (Reader.Read()) callback(Reader); |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
113 } |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
114 } |
4b78cc5f116b
Fixes and improvements (some untested)
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
115 } |
0 | 116 } |
117 | |
118 /*public DBReader GetReader(string QueryString, params object[] Parameters) { | |
119 return new DBReader(PrepareQuery(QueryString, Parameters)); | |
120 }*/ | |
85
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
121 |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
122 public IDataReader ExecuteReader(String QueryString, params Object[] Parameters) { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
123 IDbConnection connection = GetConnection(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
124 try { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
125 using (IDbCommand command = PrepareQuery(connection, QueryString, Parameters)) { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
126 return command.ExecuteReader(CommandBehavior.CloseConnection); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
127 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
128 } catch { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
129 connection.Dispose(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
130 throw; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
131 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
132 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
133 |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
134 public IEnumerable<IDataRecord> EnumerateRows(String query, params Object[] parameters) { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
135 IDbConnection connection = GetConnection(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
136 try { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
137 return new DataEnumerator(PrepareQuery(connection, query, parameters)); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
138 } catch { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
139 connection.Dispose(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
140 throw; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
141 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
142 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
143 |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
144 class DataEnumerator : IEnumerable<IDataRecord>, IEnumerator<IDataRecord> { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
145 IDbCommand command = null; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
146 IDataReader reader = null; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
147 public DataEnumerator(IDbCommand command) { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
148 this.command = command; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
149 try { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
150 this.reader = command.ExecuteReader(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
151 } catch { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
152 Dispose(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
153 throw; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
154 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
155 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
156 IEnumerator<IDataRecord> IEnumerable<IDataRecord>.GetEnumerator() { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
157 return this; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
158 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
159 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
160 return this; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
161 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
162 public IDataRecord Current { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
163 get { return reader; } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
164 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
165 object System.Collections.IEnumerator.Current { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
166 get { return reader; } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
167 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
168 public bool MoveNext() { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
169 return reader.Read(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
170 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
171 public void Reset() { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
172 throw new NotSupportedException(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
173 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
174 public Object[] CurrentRow { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
175 get { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
176 object[] array = new object[reader.FieldCount]; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
177 reader.GetValues(array); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
178 return array; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
179 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
180 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
181 public void Dispose() { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
182 if (reader != null) reader.Dispose(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
183 if (command != null) { |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
184 IDbConnection connection = command.Connection; |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
185 command.Dispose(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
186 connection.Dispose(); |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
187 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
188 } |
40715b34d0d3
Added new functions to Database class
Ivo Smits <Ivo@UCIS.nl>
parents:
7
diff
changeset
|
189 } |
0 | 190 } |
191 } |