I get an InvalidOperation error when the mscorlib.dll error occurs in the following query and cannot figure out why for life.
Here is the class that I populate List (Of) with
Public Class ProjectionPerformance
Public SymbolId As Long
Public Name As String
Public ProjectionDate As String
Public ActualRange As Double
Public ProjectedRange As Double
End Class
These types correspond to the types in the table, except for the date that I convert to a string
Here is the LINQ query function
Public Shared Function GetRangeProjectionPerformance(Optional daysToRetrieve As Integer = 100) As Dictionary(Of Long, List(Of ProjectionPerformance))
Dim todaysDate As Date = DateTime.Now.Date
Dim lookbackDate As Date = todaysDate.AddDays(daysToRetrieve * -1)
Using ctx As New ProjectionsEntities
Dim query = (From d In ctx.projections
Where d.SymbolId <= 42 AndAlso d.Date >= lookbackDate
Join t In ctx.symbols On d.SymbolId Equals t.Id
Let actualRange = d.ActualHigh - d.ActualLow
Let projectedRange = d.HighProjection - d.LowProjection
Select New With {
d.Date,
d.SymbolId,
t.Name,
projectedRange,
actualRange}).GroupBy(Function(o) o.SymbolId).ToDictionary(Function(p) p.Key,
Function(x) x.Select(Function(y) New ProjectionPerformance() With {
.SymbolId = y.SymbolId,
.ProjectionDate = y.Date.ToString(),
.Name = y.Name,
.ActualRange = y.actualRange,
.ProjectedRange = y.projectedRange
}).ToList())
Return query
End Using
End Function
I get this error in this part of the LINQ query (Im assuming this part is highlighted in green in VS2013)
Function(x) x.Select(Function(y) New ProjectionPerformance() With {
Do I need to retrieve the actual field values and exclude Let statements and do the calculations in the List function to invoke the dictionary?
source
share