Esempio n. 1
0
		/// <summary>
		/// Resets this enumerator.
		/// </summary>
		public override void Reset()
		{
			if( _Surrogate != null ) { _Surrogate.Dispose(); _Surrogate = null; }
			_Schema = null;
			_CurrentRecord = null;
		}
Esempio n. 2
0
		internal void Reset()
		{
			_WeakReference = null;
			_State = KMaps.MetaState.Empty; // By default...
			_Map = null;
			_Record = null; // Do not dispose, might be in use elsewhere...
		}
Esempio n. 3
0
		/// <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;
		}
Esempio n. 4
0
		// --------------------------------------------------
		internal static KMetaEntity First( IKMap map, KRecord find )
		{
			if( map == null ) throw new ArgumentNullException( "map", "Map cannot be null." );
			if( find == null ) throw new ArgumentNullException( "find", "KRecord cannot be null." );
			if( find.Count == 0 ) throw new ArgumentException( "Find record contains no columns." );

			lock( _SyncRoot ) {
				foreach( var meta in _MetaEntities ) {
					if( meta.Host == null ) continue;
					if( meta.Record == null ) continue;
					if( meta.Map != map ) continue;

					if( !find.EquivalentTo( meta.Record, strict: false ) ) continue;
					return meta;
				}
			}
			return null;
		}