<Test()> _
Public Sub CountOverSimpleQueryWithNullableFieldComparison()
Using adapter As New DataAccessAdapter()
Dim metaData As New LinqMetaData(adapter)
Dim ot As New OrderEntity()
ot.EmployeeId = 4
Dim cid As String = "ALFKI"
Dim q = From o In metaData.Order _
Where o.EmployeeId = ot.EmployeeId AndAlso o.CustomerId = cid _
Select o.CustomerId, o.OrderId
Dim count As Integer = q.Count()
Assert.AreEqual(2, count)
End Using
End Sub
Indeed gives a lame error, which is very strange as the expression tree should be the same, right? (lovely Microsoft, they of course didn't provide any info on these kind of problems.)
though when I do:
<Test()> _
Public Sub CountOverSimpleQueryWithNullableFieldComparison()
Using adapter As New DataAccessAdapter()
Dim metaData As New LinqMetaData(adapter)
Dim ot As New OrderEntity()
ot.EmployeeId = 4
Dim cid As String = "ALFKI"
Dim q = From o In metaData.Order _
Where o.EmployeeId.Value = ot.EmployeeId.Value AndAlso o.CustomerId = cid _
Select o.CustomerId, o.OrderId
Dim count As Integer = q.Count()
Assert.AreEqual(2, count)
End Using
End Sub
(mind the .Value on both sides!) it works. Albeit in a less efficient query than in C# thanks to the VB.NET compiler people who think that querying a database should be the same as querying an in-memory object graph which obeys the insane VB.NET nullability comparison rules.
)
Will look into making this less problematic. You should use .Value on both sides to make this work.
DQE tracing