/// <summary> /// Executes the command and returns the number of affected records. /// </summary> /// <returns>The number of records affected.</returns> public override int Execute() { var surrogate = new KSurrogate( this.Command, iterable: false ); int r = surrogate._NonQueryResult; surrogate.Dispose(); surrogate = null; return r; }
/// <summary> /// Advances this enumerator to return the next element from the database. /// <para>In this implementation these elements are not maintained in an in-memory structure, but rather are retrieved /// and maintained in the CurrentRecord property just until the next invocation of MoveNext(). /// </summary> /// <returns>True if the next element has been obtained, false if there are no more elements available.</returns> public override bool MoveNext() { // First iteration... if( _Surrogate == null ) { _Surrogate = new KSurrogate( this.Command, iterable: true ); _Schema = _Surrogate._Schema; } // If we have finished, cleaning it up... if( !_Surrogate._DataReader.Read() ) { DEBUG.IndentLine( "\n-- MoveNext: null" ); DEBUG.Unindent(); _Surrogate.Dispose(); _Surrogate = null; return false; } // Else, generating the record... _CurrentRecord = new KRecord( _Schema ); for( int i = 0; i < _Schema.Count; i++ ) { object value = _Surrogate._DataReader.IsDBNull( i ) ? null : _Surrogate._DataReader.GetValue( i ); _CurrentRecord[i] = value; } DEBUG.IndentLine( "\n-- MoveNext: {0}", CurrentRecord.ToString() ); DEBUG.Unindent(); return true; }
/// <summary> /// Resets this enumerator. /// </summary> public override void Reset() { if( _Surrogate != null ) { _Surrogate.Dispose(); _Surrogate = null; } _Schema = null; _CurrentRecord = null; }