protected QueryResultPart GetResultPart(int resultId, int startRow, int countRows)
        {
            AssertNotDisposed();

            QueryResult table = GetResult(resultId);

            if (table == null)
            {
                throw new DatabaseException("'resultId' invalid.");
            }

            int rowEnd = startRow + countRows;

            if (startRow < 0 || startRow >= table.RowCount ||
                rowEnd > table.RowCount)
            {
                throw new DatabaseException("Result part out of range.");
            }

            try {
                int colCount = table.ColumnCount;
                var block    = new QueryResultPart(colCount);
                for (int r = startRow; r < rowEnd; ++r)
                {
                    var row = new object[colCount];
                    for (int c = 0; c < colCount; ++c)
                    {
                        TObject value = table.GetCellContents(c, r);

                        // If this is a IRef, we must assign it a streamable object
                        // id that the client can use to access the large object.
                        object clientOb;
                        if (value.Object is IRef)
                        {
                            var reference = (IRef)value.Object;
                            clientOb = new StreamableObject(reference.Type, reference.RawSize, reference.Id);
                        }
                        else
                        {
                            clientOb = value.Object;
                        }

                        row[c] = clientOb;
                    }

                    block.AddRow(row);
                }
                return(block);
            } catch (Exception e) {
                Logger.Warning(this, e);
                // If an exception was generated while getting the cell contents, then
                // throw an DataException.
                throw new DatabaseException("Exception while reading results: " + e.Message, e);
            }
        }
Exemplo n.º 2
0
        protected QueryResultPart GetResultPart(int resultId, int startRow, int countRows)
        {
            AssertNotDisposed();

            QueryResult table = GetResult(resultId);
            if (table == null)
                throw new DatabaseException("'resultId' invalid.");

            int rowEnd = startRow + countRows;

            if (startRow < 0 || startRow >= table.RowCount ||
                rowEnd > table.RowCount) {
                throw new DatabaseException("Result part out of range.");
            }

            try {
                int colCount = table.ColumnCount;
                var block = new QueryResultPart(colCount);
                for (int r = startRow; r < rowEnd; ++r) {
                    var row = new object[colCount];
                    for (int c = 0; c < colCount; ++c) {
                        TObject value = table.GetCellContents(c, r);

                        // If this is a IRef, we must assign it a streamable object
                        // id that the client can use to access the large object.
                        object clientOb;
                        if (value.Object is IRef) {
                            var reference = (IRef) value.Object;
                            clientOb = new StreamableObject(reference.Type, reference.RawSize, reference.Id);
                        } else {
                            clientOb = value.Object;
                        }

                        row[c] = clientOb;
                    }

                    block.AddRow(row);
                }
                return block;
            } catch (Exception e) {
                Logger.Warning(this, e);
                // If an exception was generated while getting the cell contents, then
                // throw an DataException.
                throw new DatabaseException("Exception while reading results: " + e.Message, e);
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public ResultPart GetResultPart(int resultId, int startRow, int countRows)
        {
            CheckNotDisposed();

            ResultSetInfo table = GetResultSet(resultId);
            if (table == null)
                throw new DbDataException("'resultId' invalid.", null, 4, (Exception) null);

            int rowEnd = startRow + countRows;

            if (startRow < 0 || startRow >= table.RowCount ||
                rowEnd > table.RowCount) {
                throw new DbDataException("Result part out of range.", null, 4, (Exception) null);
            }

            try {
                int colCount = table.ColumnCount;
                ResultPart block = new ResultPart(countRows*colCount);
                for (int r = startRow; r < rowEnd; ++r) {
                    for (int c = 0; c < colCount; ++c) {
                        TObject value = table.GetCellContents(c, r);

                        // If this is a IRef, we must assign it a streamable object
                        // id that the client can use to access the large object.
                        object clientOb;
                        if (value.Object is IRef) {
                            IRef reference = (IRef) value.Object;
                            clientOb = new StreamableObject(reference.Type, reference.RawSize, reference.Id);
                        } else {
                            clientOb = value.Object;
                        }

                        block.Add(clientOb);
                    }
                }
                return block;
            } catch (Exception e) {
                Logger.Warning(this, e);
                // If an exception was generated while getting the cell contents, then
                // throw an DataException.
                throw new DbDataException("Exception while reading results: " + e.Message, e.Message, 4, e);
            }
        }