public long CopyTo(long sourceOffset, OracleLob destination, long destinationOffset, long amount)
 {
     this.AssertInternalLobIsValid();
     if (destination == null)
     {
         throw System.Data.Common.ADP.ArgumentNull("destination");
     }
     if (destination.IsNull)
     {
         throw System.Data.Common.ADP.LobWriteInvalidOnNull();
     }
     if (this._lob.IsNull)
     {
         return 0L;
     }
     this._lob.AssertConnectionIsOpen();
     this._lob.AssertAmountIsValid(amount, "amount");
     this._lob.AssertAmountIsValid(sourceOffset, "sourceOffset");
     this._lob.AssertAmountIsValid(destinationOffset, "destinationOffset");
     this._lob.AssertTransactionExists();
     long num = Math.Min(this.Length - sourceOffset, amount);
     long num4 = destinationOffset + 1L;
     long num3 = sourceOffset + 1L;
     if (0L >= num)
     {
         return 0L;
     }
     int rc = TracedNativeMethods.OCILobLoadFromFile(this.ServiceContextHandle, this.ErrorHandle, destination.Descriptor, this.Descriptor, (uint) num, (uint) num4, (uint) num3);
     if (rc != 0)
     {
         this.Connection.CheckError(this.ErrorHandle, rc);
     }
     return num;
 }
Пример #2
0
        /// <include file='doc\OracleBFile.uex' path='docs/doc[@for="OracleBFile.CopyTo3"]/*' />
        public long CopyTo(
            long sourceOffset,
            OracleLob destination,
            long destinationOffset,
            long amount
            )
        {
            // Copies a range of elements from the lob to a compatible lob, starting at the specified index of the target array.
            AssertInternalLobIsValid();

            if (null == destination)
            {
                throw ADP.ArgumentNull("destination");
            }

            if (destination.IsNull)
            {
                throw ADP.LobWriteInvalidOnNull();
            }

            if (_lob.IsNull)
            {
                return(0);
            }

            _lob.AssertConnectionIsOpen();

            _lob.AssertAmountIsValid(amount, "amount");
            _lob.AssertAmountIsValid(sourceOffset, "sourceOffset");
            _lob.AssertAmountIsValid(destinationOffset, "destinationOffset");

            _lob.AssertTransactionExists();

            int rc;

            _lob.EnsureBuffering(false);
            destination.EnsureBuffering(false);

            long dataCount = Math.Min(Length - sourceOffset, amount);
            long dstOffset = destinationOffset + 1;             // Oracle is 1 based, we are zero based.
            long srcOffset = sourceOffset + 1;                  // Oracle is 1 based, we are zero based.

            if (0 >= dataCount)
            {
                return(0);
            }

            rc = TracedNativeMethods.OCILobLoadFromFile(
                ServiceContextHandle,
                ErrorHandle,
                destination.Descriptor,
                Descriptor,
                (UInt32)dataCount,
                (UInt32)dstOffset,
                (UInt32)srcOffset
                );
            if (0 != rc)
            {
                Connection.CheckError(ErrorHandle, rc);
            }

            // DEVNOTE: Oracle must not do partial copies, because their API doesn't tell you how many bytes were copied.
            return(dataCount);
        }