DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Protected Member Functions | Package Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Client.DeveelDbDataReader Class Reference
Inheritance diagram for Deveel.Data.Client.DeveelDbDataReader:

Public Member Functions

override void Close ()
 
override DataTable GetSchemaTable ()
 
override bool NextResult ()
 
override bool Read ()
 
override bool GetBoolean (int ordinal)
 
override byte GetByte (int ordinal)
 
override long GetBytes (int ordinal, long dataOffset, byte[] buffer, int bufferOffset, int length)
 
override char GetChar (int ordinal)
 
override long GetChars (int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length)
 
override Guid GetGuid (int ordinal)
 
override short GetInt16 (int ordinal)
 
override int GetInt32 (int ordinal)
 
override long GetInt64 (int ordinal)
 
override DateTime GetDateTime (int ordinal)
 
override string GetString (int ordinal)
 
override object GetValue (int ordinal)
 
override int GetValues (object[] values)
 
override bool IsDBNull (int ordinal)
 
override decimal GetDecimal (int ordinal)
 
override double GetDouble (int ordinal)
 
override float GetFloat (int ordinal)
 
override string GetName (int ordinal)
 
override int GetOrdinal (string name)
 
override string GetDataTypeName (int ordinal)
 
override Type GetFieldType (int ordinal)
 
override Type GetProviderSpecificFieldType (int ordinal)
 
override object GetProviderSpecificValue (int ordinal)
 
override IEnumerator GetEnumerator ()
 

Protected Member Functions

override void Dispose (bool disposing)
 

Package Functions

 DeveelDbDataReader (DeveelDbCommand command, CommandBehavior behavior)
 

Properties

bool CloseConnection [get]
 
bool IsSequential [get]
 
override int Depth [get]
 
override bool IsClosed [get]
 
override int RecordsAffected [get]
 
override int FieldCount [get]
 
override object this[int ordinal] [get]
 
override object this[string name] [get]
 
override bool HasRows [get]
 

Private Member Functions

GetFinalValue< T > (int ordinal)
 
object GetRuntimeValue (int ordinal)
 
ISqlObject GetRawValue (int ordinal)
 
QueryResultColumn GetColumn (int offset)
 
int FindColumnIndex (string name)
 

Private Attributes

readonly DeveelDbCommand command
 
readonly CommandBehavior behavior
 
bool wasRead
 

Detailed Description

Definition at line 31 of file DeveelDbDataReader.cs.

Constructor & Destructor Documentation

Deveel.Data.Client.DeveelDbDataReader.DeveelDbDataReader ( DeveelDbCommand  command,
CommandBehavior  behavior 
)
inlinepackage

Definition at line 37 of file DeveelDbDataReader.cs.

37  {
38  this.command = command;
39  this.behavior = behavior;
40  }

Member Function Documentation

override void Deveel.Data.Client.DeveelDbDataReader.Close ( )
inline

Definition at line 92 of file DeveelDbDataReader.cs.

92  {
93  try {
95 
96  if (CloseConnection)
98  } catch (Exception ex) {
99  throw new DeveelDbException("An error occurred while closing the reader", ex);
100  } finally {
101  if (!CloseConnection)
103  }
104  }
new DeveelDbConnection Connection
override void Deveel.Data.Client.DeveelDbDataReader.Dispose ( bool  disposing)
inlineprotected

Definition at line 106 of file DeveelDbDataReader.cs.

106  {
107  if (disposing) {
108  Close();
109  }
110 
111  base.Dispose(disposing);
112  }
int Deveel.Data.Client.DeveelDbDataReader.FindColumnIndex ( string  name)
inlineprivate

Definition at line 88 of file DeveelDbDataReader.cs.

88  {
90  }
int FindColumnIndex(string name)
Searches for the index of the column with the given name.
override bool Deveel.Data.Client.DeveelDbDataReader.GetBoolean ( int  ordinal)
inline

Definition at line 217 of file DeveelDbDataReader.cs.

217  {
218  return GetFinalValue<bool>(ordinal);
219  }
override byte Deveel.Data.Client.DeveelDbDataReader.GetByte ( int  ordinal)
inline

Definition at line 221 of file DeveelDbDataReader.cs.

221  {
222  return GetFinalValue<byte>(ordinal);
223  }
override long Deveel.Data.Client.DeveelDbDataReader.GetBytes ( int  ordinal,
long  dataOffset,
byte[]  buffer,
int  bufferOffset,
int  length 
)
inline

Definition at line 225 of file DeveelDbDataReader.cs.

225  {
226  throw new NotImplementedException();
227  }
override char Deveel.Data.Client.DeveelDbDataReader.GetChar ( int  ordinal)
inline

Definition at line 229 of file DeveelDbDataReader.cs.

229  {
230  return GetFinalValue<char>(ordinal);
231  }
override long Deveel.Data.Client.DeveelDbDataReader.GetChars ( int  ordinal,
long  dataOffset,
char[]  buffer,
int  bufferOffset,
int  length 
)
inline

Definition at line 233 of file DeveelDbDataReader.cs.

233  {
234  throw new NotImplementedException();
235  }
QueryResultColumn Deveel.Data.Client.DeveelDbDataReader.GetColumn ( int  offset)
inlineprivate

Definition at line 84 of file DeveelDbDataReader.cs.

84  {
85  return command.CurrentResult.GetColumn(offset);
86  }
QueryResultColumn GetColumn(int offset)
override string Deveel.Data.Client.DeveelDbDataReader.GetDataTypeName ( int  ordinal)
inline

Definition at line 327 of file DeveelDbDataReader.cs.

327  {
328  var column = command.CurrentResult.GetColumn(ordinal);
329  if (column == null)
330  return null;
331 
332  return column.Type.ToString().ToUpperInvariant();
333  }
override string ToString()
Definition: SqlType.cs:395
QueryResultColumn GetColumn(int offset)
override DateTime Deveel.Data.Client.DeveelDbDataReader.GetDateTime ( int  ordinal)
inline

Definition at line 253 of file DeveelDbDataReader.cs.

253  {
254  throw new NotImplementedException();
255  }
override decimal Deveel.Data.Client.DeveelDbDataReader.GetDecimal ( int  ordinal)
inline

Definition at line 294 of file DeveelDbDataReader.cs.

294  {
295  throw new NotImplementedException();
296  }
override double Deveel.Data.Client.DeveelDbDataReader.GetDouble ( int  ordinal)
inline

Definition at line 298 of file DeveelDbDataReader.cs.

298  {
299  return GetFinalValue<double>(ordinal);
300  }
override IEnumerator Deveel.Data.Client.DeveelDbDataReader.GetEnumerator ( )
inline

Definition at line 351 of file DeveelDbDataReader.cs.

351  {
352  return new DbEnumerator(this);
353  }
override Type Deveel.Data.Client.DeveelDbDataReader.GetFieldType ( int  ordinal)
inline

Definition at line 335 of file DeveelDbDataReader.cs.

335  {
336  throw new NotImplementedException();
337  }
T Deveel.Data.Client.DeveelDbDataReader.GetFinalValue< T > ( int  ordinal)
inlineprivate
Type Constraints
T :IConvertible 

Definition at line 50 of file DeveelDbDataReader.cs.

50  : IConvertible {
51  var value = GetRuntimeValue(ordinal);
52  if (value == null || value == DBNull.Value)
53  return default(T);
54 
55  if (value is T)
56  return (T)value;
57 
58  if (!(value is IConvertible))
59  throw new InvalidCastException(String.Format("Cannot convert '{0}' to type '{1}'.", GetName(ordinal), typeof(T)));
60 
61  // TODO: Get the culture from the column and use it to convert ...
62  return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
63  }
A long string in the system.
override string GetName(int ordinal)
override float Deveel.Data.Client.DeveelDbDataReader.GetFloat ( int  ordinal)
inline

Definition at line 302 of file DeveelDbDataReader.cs.

302  {
303  return GetFinalValue<float>(ordinal);
304  }
override Guid Deveel.Data.Client.DeveelDbDataReader.GetGuid ( int  ordinal)
inline

Definition at line 237 of file DeveelDbDataReader.cs.

237  {
238  throw new NotImplementedException();
239  }
override short Deveel.Data.Client.DeveelDbDataReader.GetInt16 ( int  ordinal)
inline

Definition at line 241 of file DeveelDbDataReader.cs.

241  {
242  return GetFinalValue<short>(ordinal);
243  }
override int Deveel.Data.Client.DeveelDbDataReader.GetInt32 ( int  ordinal)
inline

Definition at line 245 of file DeveelDbDataReader.cs.

245  {
246  return GetFinalValue<int>(ordinal);
247  }
override long Deveel.Data.Client.DeveelDbDataReader.GetInt64 ( int  ordinal)
inline

Definition at line 249 of file DeveelDbDataReader.cs.

249  {
250  return GetFinalValue<long>(ordinal);
251  }
override string Deveel.Data.Client.DeveelDbDataReader.GetName ( int  ordinal)
inline

Definition at line 306 of file DeveelDbDataReader.cs.

306  {
307  string columnName = command.CurrentResult.GetColumn(ordinal).Name;
308  if (String.IsNullOrEmpty(columnName))
309  return String.Empty;
310  if (columnName.Length <= 2)
311  return columnName;
312 
313  if (columnName[0] == '@') {
314  if (columnName == "@aresult")
315  return String.Empty;
316 
317  columnName = columnName.Substring(2);
318  }
319 
320  return columnName;
321  }
A long string in the system.
string Name
Returns the name of the field.
QueryResultColumn GetColumn(int offset)
override int Deveel.Data.Client.DeveelDbDataReader.GetOrdinal ( string  name)
inline

Definition at line 323 of file DeveelDbDataReader.cs.

323  {
324  return FindColumnIndex(name);
325  }
override Type Deveel.Data.Client.DeveelDbDataReader.GetProviderSpecificFieldType ( int  ordinal)
inline

Definition at line 339 of file DeveelDbDataReader.cs.

339  {
340  var column = command.CurrentResult.GetColumn(ordinal);
341  if (column == null)
342  return null;
343 
344  return column.ValueType;
345  }
QueryResultColumn GetColumn(int offset)
override object Deveel.Data.Client.DeveelDbDataReader.GetProviderSpecificValue ( int  ordinal)
inline

Definition at line 347 of file DeveelDbDataReader.cs.

347  {
348  return GetRawValue(ordinal);
349  }
ISqlObject Deveel.Data.Client.DeveelDbDataReader.GetRawValue ( int  ordinal)
inlineprivate

Definition at line 76 of file DeveelDbDataReader.cs.

76  {
77  if ((behavior & CommandBehavior.SchemaOnly) != 0)
78  return null;
79 
80  return command.CurrentResult.GetRawColumn(ordinal);
81  }
object Deveel.Data.Client.DeveelDbDataReader.GetRuntimeValue ( int  ordinal)
inlineprivate

Definition at line 65 of file DeveelDbDataReader.cs.

65  {
66  if ((behavior & CommandBehavior.SchemaOnly) != 0)
67  return null;
68 
69  var value = command.CurrentResult.GetRuntimeValue(ordinal);
70  if (value == null || value == DBNull.Value)
71  return DBNull.Value;
72 
73  return value;
74  }
override DataTable Deveel.Data.Client.DeveelDbDataReader.GetSchemaTable ( )
inline

Definition at line 114 of file DeveelDbDataReader.cs.

114  {
115  if (FieldCount == 0)
116  return null;
117 
118  var table = new SysDataTable("ColumnsInfo");
119 
120  table.Columns.Add("Schema", typeof (string));
121  table.Columns.Add("Table", typeof (string));
122  table.Columns.Add("Name", typeof (string));
123  table.Columns.Add("FullName", typeof (string));
124  table.Columns.Add("SqlType", typeof (int));
125  table.Columns.Add("DbType", typeof (string));
126  table.Columns.Add("Type", typeof (string));
127  table.Columns.Add("Size", typeof (int));
128  table.Columns.Add("Scale", typeof (int));
129  table.Columns.Add("IsUnique", typeof (bool));
130  table.Columns.Add("IsNotNull", typeof (bool));
131  table.Columns.Add("IsSizeable", typeof (bool));
132  table.Columns.Add("IsNumeric", typeof (bool));
133  table.Columns.Add("UniqueGroup", typeof (int));
134 
135  for (int i = 0; i < FieldCount; i++) {
136  var row = table.NewRow();
137 
138  var column = GetColumn(i);
139 
140  string fullColumnName = column.Name;
141 
142  string schemaName = null;
143  string tableName = null;
144  string columnName = column.Name;
145  if (columnName.StartsWith("@f")) {
146  // this is a field, so take the table and schema of the field...
147  columnName = columnName.Substring(2, columnName.Length - 2);
148  fullColumnName = columnName;
149 
150  int index = columnName.IndexOf('.');
151  schemaName = columnName.Substring(0, index);
152  columnName = columnName.Substring(index + 1);
153 
154  index = columnName.IndexOf('.');
155  tableName = columnName.Substring(0, index);
156  columnName = columnName.Substring(index + 1);
157  } else if (columnName.StartsWith("@a")) {
158  // this is an alias: strip out the leading indicator...
159  columnName = columnName.Substring(2, columnName.Length - 2);
160  fullColumnName = columnName;
161  }
162 
163  row["Schema"] = schemaName;
164  row["Table"] = tableName;
165  row["Name"] = columnName;
166  row["FullName"] = fullColumnName;
167  row["SqlType"] = (int) column.Type.TypeCode;
168  row["DbType"] = column.Type.Name;
169  row["Size"] = column.Size;
170  row["Scale"] = column.Scale;
171  row["IsUnique"] = column.IsUnique;
172  row["IsQuantifiable"] = column.Type is ISizeableType;
173  row["IsNumeric"] = column.IsNumericType;
174  row["IsNotNull"] = column.IsNotNull;
175  row["UniqueGroup"] = column.UniqueGroup;
176 
177  table.Rows.Add(row);
178  }
179 
180  return table;
181  }
QueryResultColumn GetColumn(int offset)
System.Data.DataTable SysDataTable
override string Deveel.Data.Client.DeveelDbDataReader.GetString ( int  ordinal)
inline

Definition at line 257 of file DeveelDbDataReader.cs.

257  {
258  return GetFinalValue<string>(ordinal);
259  }
override object Deveel.Data.Client.DeveelDbDataReader.GetValue ( int  ordinal)
inline

Definition at line 261 of file DeveelDbDataReader.cs.

261  {
262  return GetRuntimeValue(ordinal);
263  }
override int Deveel.Data.Client.DeveelDbDataReader.GetValues ( object[]  values)
inline

Definition at line 265 of file DeveelDbDataReader.cs.

265  {
266  var colCount = System.Math.Min(FieldCount, values.Length);
267  for (int i = 0; i < colCount; i++) {
268  values[i] = GetValue(i);
269  }
270 
271  return colCount;
272  }
override object GetValue(int ordinal)
override bool Deveel.Data.Client.DeveelDbDataReader.IsDBNull ( int  ordinal)
inline

Definition at line 274 of file DeveelDbDataReader.cs.

274  {
275  return GetRuntimeValue(ordinal) == DBNull.Value;
276  }
override bool Deveel.Data.Client.DeveelDbDataReader.NextResult ( )
inline

Definition at line 183 of file DeveelDbDataReader.cs.

183  {
184  return command.NextResult();
185  }
override bool Deveel.Data.Client.DeveelDbDataReader.Read ( )
inline

Definition at line 187 of file DeveelDbDataReader.cs.

187  {
188  if (wasRead && ((behavior & CommandBehavior.SingleRow)) != 0)
189  return false;
190 
191  if (command.CurrentResult.Next()) {
192  wasRead = true;
193  return true;
194  }
195 
196  return false;
197  }

Member Data Documentation

readonly CommandBehavior Deveel.Data.Client.DeveelDbDataReader.behavior
private

Definition at line 33 of file DeveelDbDataReader.cs.

readonly DeveelDbCommand Deveel.Data.Client.DeveelDbDataReader.command
private

Definition at line 32 of file DeveelDbDataReader.cs.

bool Deveel.Data.Client.DeveelDbDataReader.wasRead
private

Definition at line 35 of file DeveelDbDataReader.cs.

Property Documentation

bool Deveel.Data.Client.DeveelDbDataReader.CloseConnection
getprivate

Definition at line 42 of file DeveelDbDataReader.cs.

override int Deveel.Data.Client.DeveelDbDataReader.Depth
get

Definition at line 199 of file DeveelDbDataReader.cs.

override int Deveel.Data.Client.DeveelDbDataReader.FieldCount
get

Definition at line 278 of file DeveelDbDataReader.cs.

override bool Deveel.Data.Client.DeveelDbDataReader.HasRows
get

Definition at line 290 of file DeveelDbDataReader.cs.

override bool Deveel.Data.Client.DeveelDbDataReader.IsClosed
get

Definition at line 203 of file DeveelDbDataReader.cs.

bool Deveel.Data.Client.DeveelDbDataReader.IsSequential
getprivate

Definition at line 46 of file DeveelDbDataReader.cs.

override int Deveel.Data.Client.DeveelDbDataReader.RecordsAffected
get

Definition at line 207 of file DeveelDbDataReader.cs.

override object Deveel.Data.Client.DeveelDbDataReader.this[int ordinal]
get

Definition at line 282 of file DeveelDbDataReader.cs.

override object Deveel.Data.Client.DeveelDbDataReader.this[string name]
get

Definition at line 286 of file DeveelDbDataReader.cs.


The documentation for this class was generated from the following file: