RepoDB icon indicating copy to clipboard operation
RepoDB copied to clipboard

Bug: Before/AfterExecuteQuery and similar methods not being called.

Open DarkRoku12 opened this issue 4 years ago • 4 comments

Bug Description

ITrace interface contains a definition for Before and After callbacks for:

  • ExecuteNonQuery
  • ExecuteQuery
  • ExecuteQueryMultiple
  • ExecuteReader
  • ExecuteScalar

But none of these callbacks are beign called.

Other methods have internally something like this:

            // Before Execution
            if (trace != null)
            {
                sessionId = Guid.NewGuid();
                var cancellableTraceLog = new CancellableTraceLog(sessionId, context.CommandText, entity, null);
                trace.BeforeInsert(cancellableTraceLog);
                if (cancellableTraceLog.IsCancelled)
                {
                    if (cancellableTraceLog.IsThrowException)
                    {
                        throw new CancelledExecutionException(context.CommandText);
                    }
                    return default(TResult);
                }
                context.CommandText = (cancellableTraceLog.Statement ?? context.CommandText);
                entity = (TEntity)(cancellableTraceLog.Parameter ?? entity);
            }
            // After Execution
            if (trace != null)
            {
                trace.AfterInsert(new TraceLog(sessionId, context.CommandText, entity, result,
                    DateTime.UtcNow.Subtract(beforeExecutionTime)));
            }

But the implementations of those Execute* methods at RepoDB/RepoDb.Core/RepoDb/DbRepository.cs is lacking of that code.

Library Version: Github Master branch.

DarkRoku12 avatar Jan 06 '21 22:01 DarkRoku12

Hey, thank you for reporting this issue. We will cover this on the next release (minor/major).

mikependon avatar Jan 07 '21 05:01 mikependon

Hi @mikependon, any alternative for this issue?

Edwx avatar Aug 25 '22 06:08 Edwx

@Edwx - we missed this one on the last release, and we are planning to deliver a new one soon. Are you able to wait that? We are targetting the 2nd week of September.

mikependon avatar Aug 25 '22 07:08 mikependon

The reason of the delay is because of this proposal (at issue #941). We are hopeful can be completed before our target date.

mikependon avatar Aug 25 '22 07:08 mikependon