Okay, I am trying to write a LINQ query with a Join in it, using VB on .NET 4.0.
I get the red squiggle under my line of code and when I mouse over it, it shows:
“Cannot not transform LINQ”
Note the double-negative.
Anyone have a clue what this error means? Grammatically it would mean there is NO error, but I don’t know why there should even be an error message then. This “error” also kills auto-complete on the line in question, as if there actually IS an error. So I’m confused.
Here are my variable declarations:
Dim dateTimes As Date() = GetDates()
Dim readings = (
From dr As DataRow In dbReadings.Rows
Where dr("SENSORID") = sensorid
Select New Device.Reading With {
.Dated = CDate(dr("DATEDT")),
.Value = CSng(dr("VALUE")),
.Exception = CBool(dr("EXCEPTION"))
})
Here is my query which I’m being told cannot be queried:
Dim joined = From dt As Date In dateTimes
Join r As Device.Reading In readings On r.Dated = dt
Into DateTimeReadings From r In DateTimeReadings.DefaultIfEmpty()
Select r.Value
I’m trying to get a list of readings for all the date-times in dateTimes, including blank entries for dates for which there is no reading.
Try using Cast(Of T)() since you can’t use linq against data row collection
http://msdn.microsoft.com/en-us/library/bb341406.aspx#Y0
Try this (sorry, it’s in C#)