19 using System.Collections.Generic;
37 private bool OwnsConnector {
get; set; }
48 if (connector == null)
49 throw new ArgumentNullException(
"connector");
52 Connector = connector;
54 OwnsConnector =
false;
61 public bool IsClosed {
get;
private set; }
63 public string ServerVersion {
get;
private set; }
66 throw new NotSupportedException();
70 if (Connector != null)
130 throw new NotImplementedException();
134 var envelope = Connector.CreateEnvelope(serverMetadata, message);
135 var response =
Processor.ProcessMessage(envelope);
136 if (response == null)
137 throw new InvalidOperationException(
"The processor returned no response.");
139 if (response.Error != null)
140 throw new DeveelDbServerException(response.Error.ErrorMessage, response.Error.ErrorClass, response.Error.ErrorCode);
142 serverMetadata = response.Metadata;
143 return response.Message;
147 var properties =
new Dictionary<string, object>();
148 var en = ((IDictionary)Settings).GetEnumerator();
149 while (en.MoveNext()) {
150 var current = en.Entry;
151 properties.Add((
string)current.Key, current.Value);
154 return Connector.MakeEndPoint(properties);
158 if (Connector == null) {
159 Connector = CreateConnector();
163 remoteEndPoint = MakeRemoteEndPoint();
165 var request =
new ConnectRequest(Connector.LocalEndPoint, remoteEndPoint) {
166 DatabaseName = Settings.Database,
167 Timeout = Settings.QueryTimeout,
169 ParameterStyle = Settings.ParameterStyle,
170 AutoCommit = Settings.AutoCommit
174 if (response == null)
177 if (!response.Opened)
180 if (response.IsEncryted)
181 Connector.SetEncrypton(response.EncryptionData);
184 ServerVersion = response.Version;
192 if (response == null)
193 throw new InvalidOperationException();
203 var response = SendMessage(
new AuthenticateRequest(Settings.Schema, Settings.UserName, Settings.Password))
206 if (response == null)
207 throw new InvalidOperationException();
209 return response.Authenticated;
216 if (response == null)
217 throw new InvalidOperationException();
219 return response.QueryResponse;
226 if (response == null)
227 throw new InvalidOperationException();
229 return response.Part;
236 if (response == null)
237 throw new InvalidOperationException();
244 var isolation = MapIsolationLevel(isolationLevel);
245 return BeginTransaction(isolation);
249 if (isolationLevel ==
System.Data.IsolationLevel.Serializable)
251 if (isolationLevel ==
System.Data.IsolationLevel.Snapshot)
253 if (isolationLevel ==
System.Data.IsolationLevel.ReadCommitted)
255 if (isolationLevel ==
System.Data.IsolationLevel.ReadUncommitted)
258 throw new NotSupportedException(String.Format(
"Isolation Level '{0}' not supported by DeveelDB", isolationLevel));
262 var response = SendMessage(
new BeginRequest(isolationLevel))
265 if (response == null)
266 throw new InvalidOperationException();
268 return response.CommitId;
275 if (response == null)
276 throw new InvalidOperationException();
286 if (response == null)
287 throw new InvalidOperationException();
298 if (response == null)
299 throw new InvalidOperationException();
302 throw new InvalidOperationException(
"Unable to dispose the large object on the server.");
307 GC.SuppressFinalize(
this);
312 if (OwnsConnector && Connector != null) {
IMessageProcessor CreateProcessor()
This processes _queries from a client and dispatches the _queries to the database.
int BeginTransaction(System.Data.IsolationLevel isolationLevel)
IDictionary< string, object > serverMetadata
ConnectionEndPoint MakeRemoteEndPoint()
void DisposeResult(int resultId)
The response to a command executed via the IDatabaseInterface.ExecuteQuery method in the IDatabaseInt...
void CommitTransaction(int transactionId)
bool IgnoreIdentifiersCase
IMessage SendMessage(IMessage message)
ConnectionClient(IClientConnector connector, DeveelDbConnectionStringBuilder settings)
IQueryResponse[] ExecuteQuery(int commitId, SqlQuery query)
IsolationLevel MapIsolationLevel(System.Data.IsolationLevel isolationLevel)
void Dispose(bool disposing)
Defines the contract for the configuration node of a component within the system or of the system its...
QueryResultPart GetResultPart(int resultId, int rowIndex, int count)
void DisposeLargeObject(long objId)
IClientConnector CreateConnector()
int BeginTransaction(IsolationLevel isolationLevel)
IClientConnector CreateNetworkConnector()
ConnectionClient(DeveelDbConnectionStringBuilder settings)
ConnectionEndPoint remoteEndPoint
void RollbackTransaction(int transactionId)