/// <summary> /// Called by base class after creating a get/query/scan results reader /// </summary> /// <param name="reader"></param> protected override void InitReader(ISupervisableEnumerable reader) { base.InitReader(reader); // When an item is fetched from DynamoDb and enumerated - we need to keep a reference to it. // But only table entities should be registered. Projection types shouldn't. reader.EntityDocumentEnumerated += (entityDocument, entityWrapper) => { EntityKey entityKey = null; // if this is the whole entity - then attaching it if (entityWrapper != null) { entityKey = this.EntityKeyGetter.GetKey(entityDocument); this._loadedEntities[entityKey] = entityWrapper; } // also putting the entity to cache var curIndexCreator = this.CurrentIndexCreator; if (curIndexCreator != null) { curIndexCreator.AddEntityToIndex(entityKey, entityDocument); } }; }
protected virtual void InitReader(ISupervisableEnumerable reader) { // We need to detect the moment, when enumeration is finished. To put an index to cache reader.EnumerationFinished += () => { #if DEBUG if (this._loadOperationStopwatch != null) { this._loadOperationStopwatch.Stop(); this.Log("Load operation took {0} ms", this._loadOperationStopwatch.ElapsedMilliseconds); this._loadOperationStopwatch = null; } #endif // storing the filled index to cache var curIndexCreator = this.CurrentIndexCreator; if (curIndexCreator != null) { curIndexCreator.Dispose(); } this.CurrentIndexCreator = null; }; }