/// <summary>
/// Executes a query and invokes a method with a DataReader of results.
/// </summary>
/// <param name="transaction">The transaction to do this as part of.</param>
/// <param name="mapping">Class mapping for the table we're querying against. Optional,
/// but not all columns may be properly typed if it is null.</param>
/// <param name="query">The query to execute, should have come from CreateQuery.</param>
/// <param name="invokeMe">The method to invoke with the IDataReader results.</param>
/// <param name="parameters">A hashtable containing any values that need to be persisted through invoked method.
/// The list of objects from the query will be placed here.</param>
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();
}
}