Ejemplo n.º 1
0
        public QueryMetadata Aggregate()
        {
            Metadata = new QueryMetadata();

            AggregateConnectionStart();
            AggregateConnectionClosed();
            AggregateCommandErrors();
            AggregateCommandDurations();
            AggregateCommandExecuted();
            AggregateCommandRowCounts();
            AggregateTransactionBegan();
            AggregateTransactionEnd();

            return Metadata;
        }
Ejemplo n.º 2
0
        public static SqlStatistics Caluculate(QueryMetadata queryMetadata)
        {
            var queryCount = queryMetadata.Commands.Count;
            var connectionCount = queryMetadata.Connections.Count;
            var transactionCount = queryMetadata.Transactions.Count;

            var queryExecutionTime = new TimeSpan();
            var connectionOpenTime = new TimeSpan();

            queryExecutionTime = queryMetadata.Commands.Aggregate(queryExecutionTime, (totalDuration, command) => totalDuration + command.Value.Duration);
            connectionOpenTime = queryMetadata.Connections.Aggregate(connectionOpenTime, (totalDuration, connection) => totalDuration + connection.Value.Duration.GetValueOrDefault(TimeSpan.Zero));

            return new SqlStatistics(
                queryCount,
                connectionCount,
                transactionCount,
                queryExecutionTime,
                connectionOpenTime);
        }