Exemple #1
0
 /// <summary>
 /// Should be called when you're done with the query.  Allows us to cache the
 /// objects for reuse.
 /// </summary>
 /// <param name="query">Query you're done using.</param>
 public override void DisposeOfQuery(IDaQuery query)
 {
     if (query == null)
     {
         throw new ArgumentNullException("query", "Cannot dispose of null query.");
     }
     if (!(query is SqlDaQuery))
     {
         throw new ArgumentException("Cannot dispose of a query not created by me.");
     }
     SqlDaQuery sqlQuery = (SqlDaQuery) query;
     _sqlQueryCache.Return(sqlQuery);
 }
Exemple #2
0
 /// <exclude/>
 public override void ExecuteQuery(ITransaction transaction, ClassMapping mapping, IDaQuery query,
     DataReaderDelegate invokeMe, Hashtable parameters)
 {
     if (query == null)
     {
         throw new ArgumentNullException("query", "Cannot execute a null query.");
     }
     if (!(query is SqlDaQuery))
     {
         throw new ArgumentException("Cannot execute a query not created by me.");
     }
     SqlDaQuery sqlQuery = (SqlDaQuery)query;
     SqlConnectionUtilities.XSafeQuery(_connDesc, (SqlTransaction)transaction, sqlQuery.Sql.ToString(),
         sqlQuery.Params, invokeMe, parameters);
 }
Exemple #3
0
 /// <summary>
 /// Executes a query and invokes a method with a DataReader of results.
 /// </summary>
 /// <param name="transaction">Should be null, transactions are not supported.</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)
 {
     switch (_connDesc.Type)
     {
         case CsvConnectionType.Directory:
         case CsvConnectionType.FileName:
         case CsvConnectionType.Reader:
             // These are OK.
             break;
         default:
             throw new LoggingException("Connection does not support querying: " + _connDesc);
     }
     CsvDataReader reader = new CsvDataReader(this, mapping, ((UnqueryableQuery)query).Criteria);
     try
     {
         invokeMe.Invoke(parameters, reader);
     }
     finally
     {
         reader.Close();
     }
 }
Exemple #4
0
 /// <summary>
 /// Should be called when you're done with the query.  Allows us to cache the
 /// objects for reuse.
 /// </summary>
 /// <param name="query">Query you're done using.</param>
 public override void DisposeOfQuery(IDaQuery query)
 {
     _queryCache.Return((UnqueryableQuery)query);
 }
Exemple #5
0
 /// <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 abstract void ExecuteQuery(ITransaction transaction, ClassMapping mapping, IDaQuery query, DataReaderDelegate invokeMe, Hashtable parameters);
Exemple #6
0
 /// <summary>
 /// Should be called when you're done with the query.  Allows us to cache the
 /// objects for reuse.
 /// </summary>
 /// <param name="query">Query you're done using.</param>
 public abstract void DisposeOfQuery(IDaQuery query);
Exemple #7
0
 /// <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();
     }
 }