Azavea.Open.DAO.Memory.MemoryDaLayer.ExecuteQuery C# (CSharp) Method

ExecuteQuery() public method

Executes a query and invokes a method with a DataReader of results.
public ExecuteQuery ( ITransaction transaction, ClassMapping mapping, IDaQuery query, DataReaderDelegate invokeMe, Hashtable parameters ) : void
transaction ITransaction The transaction to do this as part of.
mapping ClassMapping Class mapping for the table we're querying against. Optional, /// but not all columns may be properly typed if it is null.
query IDaQuery The query to execute, should have come from CreateQuery.
invokeMe DataReaderDelegate The method to invoke with the IDataReader results.
parameters System.Collections.Hashtable A hashtable containing any values that need to be persisted through invoked method. /// The list of objects from the query will be placed here.
return void
        public override void ExecuteQuery(ITransaction transaction, ClassMapping mapping, IDaQuery query, DataReaderDelegate invokeMe, Hashtable parameters)
        {
            // Make a copy of the table and iterate over that, that way reading doesn't block writing (or
            // more reading).
            IDictionary<string, MemoryObject> tempTable;
            IDictionary<string, MemoryObject> table = GetTable(mapping);
            lock (table)
            {
                tempTable = new CheckedDictionary<string, MemoryObject>(table);
            }
            MemoryDataReader reader = new MemoryDataReader(this, mapping, ((UnqueryableQuery)query).Criteria,
                                                           tempTable.Values.GetEnumerator());
            try
            {
                invokeMe.Invoke(parameters, reader);
            }
            finally
            {
                reader.Close();
            }
        }