/// <summary> /// The execute database data reader. /// </summary> /// <param name="behavior">The behaviour.</param> /// <returns>the resulting <see cref="DbDataReader"/>.</returns> protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { if (_profiler == null || !_profiler.IsActive) { return(_command.ExecuteReader(behavior)); } DbDataReader result = null; _profiler.ExecuteStart(this, ExecuteType.Reader); try { result = _command.ExecuteReader(behavior); result = new ProfiledDbDataReader(result, _connection, _profiler); } catch (Exception e) { _profiler.OnError(this, ExecuteType.Reader, e); throw; } finally { _profiler.ExecuteFinish(this, ExecuteType.Reader, result); } return(result); }
public override IMessage Invoke(IMessage msg) { IMethodCallMessage methodMessage = new MethodCallMessageWrapper((IMethodCallMessage)msg); var executeType = GetExecuteType(methodMessage); if (executeType != ExecuteType.None) profiler.ExecuteStart(instance, executeType); object returnValue = methodMessage.MethodBase.Invoke(instance, methodMessage.Args); if (executeType == ExecuteType.Reader) returnValue = new ProfiledDbDataReader((DbDataReader)returnValue, instance.Connection, profiler); IMessage returnMessage = new ReturnMessage(returnValue, methodMessage.Args, methodMessage.ArgCount, methodMessage.LogicalCallContext, methodMessage); if (executeType == ExecuteType.Reader) profiler.ExecuteFinish(instance, executeType, (DbDataReader)returnValue); else if (executeType != ExecuteType.None) profiler.ExecuteFinish(instance, executeType, null); return returnMessage; }
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { if (_profiler == null || !_profiler.IsActive) { return _cmd.ExecuteReader(behavior); } DbDataReader result = null; _profiler.ExecuteStart(this, ExecuteType.Reader); try { result = _cmd.ExecuteReader(behavior); result = new ProfiledDbDataReader(result, _conn, _profiler); } catch (Exception e) { _profiler.OnError(this, ExecuteType.Reader, e); throw; } finally { _profiler.ExecuteFinish(this, ExecuteType.Reader, result); } return result; }