protected IQueryResponse[] CoreExecuteQuery(IQuery context, string text, IEnumerable<QueryParameter> parameters, QueryParameterStyle parameterStyle)
{
// Where Query result eventually resides.
int resultId = -1;
// For each StreamableObject in the query object, translate it to a
// IRef object that presumably has been pre-pushed onto the server from
// the client.
// Evaluate the sql Query.
var query = new SqlQuery(text, parameterStyle);
if (parameters != null) {
foreach (var p in parameters) {
var c = p.SqlType.TypeCode;
switch (c) {
case SqlTypeCode.Blob:
case SqlTypeCode.Clob:
case SqlTypeCode.LongVarBinary:
case SqlTypeCode.LongVarChar:
case SqlTypeCode.VarBinary:
throw new NotImplementedException("TODO: Download the Large-Objects and replace with a reference");
default:
query.Parameters.Add(p);
break;
}
}
}
var stopwatch = new Stopwatch();
stopwatch.Start();
var results = context.ExecuteQuery(query);
var responses = new IQueryResponse[results.Length];
int j = 0;
foreach (var result in results) {
QueryResult queryResult;
try {
if (result.Type == StatementResultType.Exception)
throw result.Error;
queryResult = new QueryResult(query, result, context.AutoCommit());
resultId = AddResult(queryResult);
} catch (Exception) {
if (resultId != -1)
DisposeResult(resultId);
throw;
}
var taken = stopwatch.ElapsedMilliseconds;
// Return the Query response
responses[j] = new QueryResponse(resultId, queryResult, (int)taken, "");
j++;
}
stopwatch.Stop();
return responses;
}