newrelic-platform/newrelic_microsoft_sqlserver_plugin — pull request #6 by tucaz (2013-06-19 20:52:35+00:00)
Title: Added test case and possible fix for issue #5

My fix consists in taking only one of the duplicated results that comes back from the query execution based on the execution count.

Possibly, the best fix would be to review the sql query and resolve this duplication there.

Looks like my indentation configuration messed up the whole file so the diff is kind of difficult to really grasp. The only change was made in SqlEndpoint.cs:191 changing

```csharp
var currentValues = sqlDmlActivities.ToDictionary(a => string.Format("{0}:{1}:{2}", BitConverter.ToString(a.PlanHandle), a.SQlStatement, a.CreationTime));
```

to

```csharp
var currentValues = sqlDmlActivities
.GroupBy(a => string.Format("{0}:{1}:{2}", BitConverter.ToString(a.PlanHandle), a.SQlStatement, a.CreationTime))
.Select(a => new { a.Key, Activity = a.OrderByDescending(x => x.ExecutionCount).First() })
.ToDictionary(a => a.Key, a => a.Activity);
```