ExecuteMultiRowDataTableRetrievalQuery Method no longer virtual ?

Posts   
 
    
IowaDave
User
Posts: 83
Joined: 02-Jun-2004
# Posted on: 07-Oct-2008 19:05:57   

In migrating from 1.0.2004.2 Final to 2.6, I find I can no longer override one of the ExecuteMultiRowDataTableRetrievalQuery methods

I see in .Net Reflector, in 1.0.2004.2, both versions of the method were virtual but in 2.6, only one is. We override the retrieval methods so we can add our error/retry logic, an important part of our application.

Can we get this changed?

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Oct-2008 06:34:57   

These are the two overloads

public DataTable ExecuteMultiRowDataTableRetrievalQuery(
     IRetrievalQuery queryToExecute, 
     DbDataAdapter dataAdapterToUse, 
     IEntityFields fieldsToReturn)
public virtual bool ExecuteMultiRowDataTableRetrievalQuery(
     IRetrievalQuery queryToExecute, 
     DbDataAdapter dataAdapterToUse, 
     DataTable tableToFill, 
     IEntityFields fieldsToReturn)

You just need to override the second, as the first actually calls the second one.

IowaDave wrote:

We override the retrieval methods so we can add our error/retry logic, an important part of our application.

Could you post the example of what were you doing on error/retry logic? maybe there's a better way of doing that in v2.6.

David Elizondo | LLBLGen Support Team
IowaDave
User
Posts: 83
Joined: 02-Jun-2004
# Posted on: 08-Oct-2008 17:39:31   
  1. I have removed the problem override method and I'm compiling fine now. Thanks for your help.

  2. Here's an example of the pattern we use to check for exceptions. We have defined properties for the number of retries allowed. Our overrides use this technique for the various retrieval methods.

    
        public override void ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFactory2 entityFactory, IEntityCollection2 collectionToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo, bool allowDuplicates, IEntityFields2 fieldsUsedForQuery)
        {
            bool done = false;
            
            //reset error counts
            ResetErrorCounts();

            // Loop until we have success or error out too many times.
            while(!done)
            {
                try
                {
                    base.ExecuteMultiRowRetrievalQuery (queryToExecute, entityFactory, collectionToFill, fieldsPersistenceInfo, allowDuplicates, fieldsUsedForQuery);
                    done = true;
                }
                catch(ORMQueryExecutionException ex)
                {
                    //error occured duing the execution of the stored procedure
                    //check to see if we are allowed to retry the sql execution
                    EvaluateExceptionsForPossibleRetries(ex);
                }
            }
        }
    private void EvaluateExceptionsForPossibleRetries(Exception exception)
        {

            // Check for general network error
            if (IsThisAGeneralNetworkError(exception))
            {
                //increment the general network error count
                _generalNetworkErrorCount++;

                if (_generalNetworkErrorCount > _numberOfGeneralNetworkErrorRetriesAllowed)
                    throw exception;
                else
                    Thread.Sleep(_sleepSecondsBetweenRetries * 1000);       // sleep time can be overrridden by a static property
            }
            // Retry for timeout errors
            else if (IsThisATimeoutError(exception))
            {   
                //increment the timeout error count
                _timeoutErrorCount++;

                if (_timeoutErrorCount > _numberOfTimeoutErrorRetriesAllowed)
                    throw exception;
                else
                {
                    CommandTimeOut *= 2;    // Double the timeout period for the next try
                    Thread.Sleep(_sleepSecondsBetweenRetries * 1000);   // sleep time can be overrridden by a static property
                }
            }
            // Retry for deadlock errors
            else if (IsThisADeadlockError(exception))
            {   
                //increment the deadlock error count
                _deadlockErrorCount++;

                if (_deadlockErrorCount > _numberOfDeadlockErrorRetriesAllowed)
                    throw exception;
                else
                {
                    Thread.Sleep(_sleepSecondsBetweenRetries * 1000);   // sleep time can be overrridden by a static property
                }
            }
            else
            {
                //unhandled error - raise exception
                throw exception;
            }
        }

        /// <summary>
        /// Resets the error counts.
        /// </summary>
        private void ResetErrorCounts()
        {
            _generalNetworkErrorCount = 0;
            _timeoutErrorCount = 0;
            _deadlockErrorCount = 0;
        }