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.DeveelDbConnection Class Reference
Inheritance diagram for Deveel.Data.Client.DeveelDbConnection:

Public Member Functions

new DeveelDbTransaction BeginTransaction (IsolationLevel isolationLevel)
 
override void Close ()
 
override void ChangeDatabase (string databaseName)
 
override void Open ()
 
new DeveelDbCommand CreateCommand ()
 

Protected Member Functions

override DbTransaction BeginDbTransaction (IsolationLevel isolationLevel)
 
override DbCommand CreateDbCommand ()
 
override void Dispose (bool disposing)
 

Package Functions

 DeveelDbConnection (IClientConnector connector, DeveelDbConnectionStringBuilder settings)
 
void ChangeState (ConnectionState newState)
 
void EndState ()
 
void CommitTransaction (int commitId)
 
void RollbackTransaction (int commitId)
 
IQueryResponse[] ExecuteQuery (int commitId, SqlQuery query)
 
QueryResultPart RequestResultPart (int resultId, int rowIndex, int rowCount)
 
void DisposeResult (int resultId)
 

Properties

ConnectionClient Client [get, set]
 
LocalRowCache RowCache [get, private set]
 
override string ConnectionString [get, set]
 
DeveelDbConnectionStringBuilder Settings [get, set]
 
override string Database [get]
 
override ConnectionState State [get]
 
override string DataSource [get]
 
override string ServerVersion [get]
 
override int ConnectionTimeout [get]
 
DeveelDbTransaction Transaction [get, set]
 

Private Member Functions

void AssertClosed ()
 
void AssertFetching ()
 
int BeginServerTransaction (IsolationLevel isolationLevel)
 

Private Attributes

DeveelDbConnectionStringBuilder connectionString
 
ConnectionState state
 
ConnectionState oldState
 
readonly object stateLock = new object()
 
string serverVersion
 
string dataSource
 
Dictionary< string, DeveelDbDataReaderopenReaders
 

Detailed Description

Definition at line 28 of file DeveelDbConnection.cs.

Constructor & Destructor Documentation

Deveel.Data.Client.DeveelDbConnection.DeveelDbConnection ( IClientConnector  connector,
DeveelDbConnectionStringBuilder  settings 
)
inlinepackage

Definition at line 40 of file DeveelDbConnection.cs.

40  {
41  Client = new ConnectionClient(connector,settings);
42  connectionString = settings;
43  RowCache = new LocalRowCache(this);
44  }
DeveelDbConnectionStringBuilder connectionString

Member Function Documentation

void Deveel.Data.Client.DeveelDbConnection.AssertClosed ( )
inlineprivate

Definition at line 187 of file DeveelDbConnection.cs.

187  {
188  if (state != ConnectionState.Closed)
189  throw new InvalidOperationException("The connection is not closed.");
190  }
void Deveel.Data.Client.DeveelDbConnection.AssertFetching ( )
inlineprivate

Definition at line 192 of file DeveelDbConnection.cs.

192  {
193  if (state != ConnectionState.Fetching)
194  throw new InvalidOperationException("The connection is not fetching data.");
195  }
override DbTransaction Deveel.Data.Client.DeveelDbConnection.BeginDbTransaction ( IsolationLevel  isolationLevel)
inlineprotected

Definition at line 64 of file DeveelDbConnection.cs.

64  {
65  return BeginTransaction(isolationLevel);
66  }
new DeveelDbTransaction BeginTransaction(IsolationLevel isolationLevel)
int Deveel.Data.Client.DeveelDbConnection.BeginServerTransaction ( IsolationLevel  isolationLevel)
inlineprivate

Definition at line 211 of file DeveelDbConnection.cs.

211  {
212  lock (this) {
213  try {
214  return Client.BeginTransaction(isolationLevel);
215  } catch (Exception ex) {
216  throw new DeveelDbException("Could not begin a transaction.", ex);
217  }
218  }
219  }
int BeginTransaction(System.Data.IsolationLevel isolationLevel)
new DeveelDbTransaction Deveel.Data.Client.DeveelDbConnection.BeginTransaction ( IsolationLevel  isolationLevel)
inline

Definition at line 50 of file DeveelDbConnection.cs.

50  {
51  if (Transaction != null)
52  throw new DeveelDbException("A transaction is already open on this connection.");
53 
54  if (isolationLevel == IsolationLevel.Unspecified)
55  isolationLevel = IsolationLevel.Serializable;
56 
57  if (isolationLevel != IsolationLevel.Serializable)
58  throw new NotSupportedException(String.Format("Isolation Level '{0}' is not supported yet.", isolationLevel));
59 
60  var commitId = BeginServerTransaction(isolationLevel);
61  return new DeveelDbTransaction(this, isolationLevel, commitId);
62  }
A long string in the system.
int BeginServerTransaction(IsolationLevel isolationLevel)
override void Deveel.Data.Client.DeveelDbConnection.ChangeDatabase ( string  databaseName)
inline

Definition at line 98 of file DeveelDbConnection.cs.

98  {
99  throw new NotImplementedException();
100  }
void Deveel.Data.Client.DeveelDbConnection.ChangeState ( ConnectionState  newState)
inlinepackage

Definition at line 197 of file DeveelDbConnection.cs.

197  {
198  lock (stateLock) {
199  if (state != newState)
200  OnStateChange(new StateChangeEventArgs(state, newState));
201 
202  oldState = state;
203  state = newState;
204  }
205  }
override void Deveel.Data.Client.DeveelDbConnection.Close ( )
inline

Definition at line 68 of file DeveelDbConnection.cs.

68  {
69  lock (this) {
70  try {
71  if (State == ConnectionState.Closed)
72  return;
73 
74  if (openReaders != null) {
75  foreach (var reader in openReaders.Values) {
76  reader.Close();
77  }
78 
79  openReaders.Clear();
80  openReaders = null;
81  }
82 
83 
84  if (Transaction != null) {
86  Transaction = null;
87  }
88 
90  } catch (Exception ex) {
91  throw new DeveelDbException("An error occurred while closing the connection.", ex);
92  } finally {
93  ChangeState(ConnectionState.Closed);
94  }
95  }
96  }
Dictionary< string, DeveelDbDataReader > openReaders
void ChangeState(ConnectionState newState)
void Deveel.Data.Client.DeveelDbConnection.CommitTransaction ( int  commitId)
inlinepackage

Definition at line 221 of file DeveelDbConnection.cs.

221  {
222  lock (this) {
223  try {
224  Client.CommitTransaction(commitId);
225  } catch (Exception ex) {
226  throw new DeveelDbException(String.Format("Could not COMMIT transaction '{0}' on the server.", commitId), ex);
227  }
228  }
229  }
A long string in the system.
void CommitTransaction(int transactionId)
new DeveelDbCommand Deveel.Data.Client.DeveelDbConnection.CreateCommand ( )
inline

Definition at line 183 of file DeveelDbConnection.cs.

183  {
184  return new DeveelDbCommand(this);
185  }
override DbCommand Deveel.Data.Client.DeveelDbConnection.CreateDbCommand ( )
inlineprotected

Definition at line 179 of file DeveelDbConnection.cs.

179  {
180  return CreateCommand();
181  }
override void Deveel.Data.Client.DeveelDbConnection.Dispose ( bool  disposing)
inlineprotected

Definition at line 265 of file DeveelDbConnection.cs.

265  {
266  if (disposing) {
267  Close();
268 
269  if (Client != null)
270  Client.Dispose();
271  }
272 
273  Client = null;
274 
275  base.Dispose(disposing);
276  }
void Deveel.Data.Client.DeveelDbConnection.DisposeResult ( int  resultId)
inlinepackage

Definition at line 257 of file DeveelDbConnection.cs.

257  {
258  try {
259  Client.DisposeResult(resultId);
260  } catch (Exception ex) {
261  throw new DeveelDbException(String.Format("The remote result '{0}' could not be disposed.", resultId), ex);
262  }
263  }
A long string in the system.
void Deveel.Data.Client.DeveelDbConnection.EndState ( )
inlinepackage

Definition at line 207 of file DeveelDbConnection.cs.

207  {
209  }
void ChangeState(ConnectionState newState)
IQueryResponse [] Deveel.Data.Client.DeveelDbConnection.ExecuteQuery ( int  commitId,
SqlQuery  query 
)
inlinepackage

Definition at line 241 of file DeveelDbConnection.cs.

241  {
242  try {
243  return Client.ExecuteQuery(commitId, query);
244  } catch (Exception ex) {
245  throw new DeveelDbException("An error occurred while executing a query.", ex);
246  }
247  }
IQueryResponse[] ExecuteQuery(int commitId, SqlQuery query)
override void Deveel.Data.Client.DeveelDbConnection.Open ( )
inline

Definition at line 102 of file DeveelDbConnection.cs.

102  {
103  lock (this) {
104  if (State == ConnectionState.Open)
105  return;
106 
107  if (State != ConnectionState.Closed)
108  return;
109 
110  try {
111  ChangeState(ConnectionState.Connecting);
112 
113  Client.Connect();
115 
117  } catch (Exception) {
118  ChangeState(ConnectionState.Broken);
119 
120  // TODO: throw a specialized exception
121  throw;
122  }
123 
124  ChangeState(ConnectionState.Open);
125  }
126  }
void ChangeState(ConnectionState newState)
QueryResultPart Deveel.Data.Client.DeveelDbConnection.RequestResultPart ( int  resultId,
int  rowIndex,
int  rowCount 
)
inlinepackage

Definition at line 249 of file DeveelDbConnection.cs.

249  {
250  try {
251  return Client.GetResultPart(resultId, rowIndex, rowCount);
252  } catch (Exception ex) {
253  throw new DeveelDbException(String.Format("Could not retrieve part of the result '{0}' from the server.", resultId), ex);
254  }
255  }
A long string in the system.
QueryResultPart GetResultPart(int resultId, int rowIndex, int count)
void Deveel.Data.Client.DeveelDbConnection.RollbackTransaction ( int  commitId)
inlinepackage

Definition at line 231 of file DeveelDbConnection.cs.

231  {
232  lock (this) {
233  try {
234  Client.RollbackTransaction(commitId);
235  } catch (Exception ex) {
236  throw new DeveelDbException(String.Format("Could not ROLLBACK transaction '{0}' on the server.", commitId), ex);
237  }
238  }
239  }
A long string in the system.
void RollbackTransaction(int transactionId)

Member Data Documentation

DeveelDbConnectionStringBuilder Deveel.Data.Client.DeveelDbConnection.connectionString
private

Definition at line 29 of file DeveelDbConnection.cs.

string Deveel.Data.Client.DeveelDbConnection.dataSource
private

Definition at line 36 of file DeveelDbConnection.cs.

ConnectionState Deveel.Data.Client.DeveelDbConnection.oldState
private

Definition at line 32 of file DeveelDbConnection.cs.

Dictionary<string, DeveelDbDataReader> Deveel.Data.Client.DeveelDbConnection.openReaders
private

Definition at line 38 of file DeveelDbConnection.cs.

string Deveel.Data.Client.DeveelDbConnection.serverVersion
private

Definition at line 35 of file DeveelDbConnection.cs.

ConnectionState Deveel.Data.Client.DeveelDbConnection.state
private

Definition at line 31 of file DeveelDbConnection.cs.

readonly object Deveel.Data.Client.DeveelDbConnection.stateLock = new object()
private

Definition at line 33 of file DeveelDbConnection.cs.

Property Documentation

ConnectionClient Deveel.Data.Client.DeveelDbConnection.Client
getsetprivate

Definition at line 46 of file DeveelDbConnection.cs.

override string Deveel.Data.Client.DeveelDbConnection.ConnectionString
getset

Definition at line 128 of file DeveelDbConnection.cs.

override int Deveel.Data.Client.DeveelDbConnection.ConnectionTimeout
get

Definition at line 173 of file DeveelDbConnection.cs.

override string Deveel.Data.Client.DeveelDbConnection.Database
get

Definition at line 142 of file DeveelDbConnection.cs.

override string Deveel.Data.Client.DeveelDbConnection.DataSource
get

Definition at line 154 of file DeveelDbConnection.cs.

LocalRowCache Deveel.Data.Client.DeveelDbConnection.RowCache
getprivate setpackage

Definition at line 48 of file DeveelDbConnection.cs.

override string Deveel.Data.Client.DeveelDbConnection.ServerVersion
get

Definition at line 169 of file DeveelDbConnection.cs.

DeveelDbConnectionStringBuilder Deveel.Data.Client.DeveelDbConnection.Settings
getsetpackage

Definition at line 133 of file DeveelDbConnection.cs.

override ConnectionState Deveel.Data.Client.DeveelDbConnection.State
get

Definition at line 146 of file DeveelDbConnection.cs.

DeveelDbTransaction Deveel.Data.Client.DeveelDbConnection.Transaction
getsetpackage

Definition at line 177 of file DeveelDbConnection.cs.


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