views:

143

answers:

0

The following lines of code is producing this error: "Overload resolution failes because no accessible 'Single' can be called with these arguments". I'm not too good with VB, but since the app I've inherited was in VB, I didn't want to rewrite it all:

Dim a1 = From rows In db.tPDMLinkUsages _
    Where (rows.ACCESSDATE >= DateTime.Today.AddDays(-90)) _
    Select New With _
    { _
       .ORGANIZATION = db.vWindchillUsers.Single(Function(v) v.USERNAME = rows.USERNAME), _
       .ACCESSDATE = rows.ACCESSDATE _
    }

 Dim newRow As DataRow = Nothing

        For Each row As UserInfo In OrgCountCol
            ' Adds a new row.
            newRow = table.NewRow()
            newRow(0) = row.OrganizationName
            newRow(1) = row.AverageDaily
            newRow(2) = row.HighWater
            table.Rows.Add(newRow)

            total += row.UniqueHits
        Next

Here is the C# version:

var a1 = from u in db.tPDMLinkUsages
         where u.ACCESSDATE >= DateTime.Today.AddDays(-90)
         select new
         {
             ORGANIZATION = db.vWindchillUsers.Single(v => v.USERNAME == u.USERNAME).ORGANIZATION,
             ACCESSDATE = u.ACCESSDATE
         };

''Then from this, you can group by the organization to build the daily averages and high water mark:

var a2 = from u in a1
         group u by u.ORGANIZATION into uGroup
         select new
         {
             ORGANIZATION = uGroup.Key,
             AVERAGEDAILY = uGroup.Count() / 90.0,
             HIGHWATER = uGroup.GroupBy(v => v.ACCESSDATE)
                               .Max(g => g.Count())
         };