It's indeed something caused by the VB.NET compiler. (C# doesn't allow you to compare two strings with '<', you have to use string.Compare):
<Test()> _
Public Sub StringCompareTest()
Using adapter As New DataAccessAdapter
Dim metaData As New LinqMetaData(adapter)
Dim q = From c In metaData.Customer Where c.CustomerId < "CCCCC" Select c
Dim count As Integer = 0
For Each v In q
count += 1
Next
Assert.AreEqual(12, count)
End Using
End Sub
results in the expression tree:
value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[NW26.Adapter.EntityClasses.CustomerEntity]).Where(c => (CompareString(c.CustomerId, "CCCCC", False) < 0)).Select(c => c)
Which shows the CompareString() call (which is a native VB.NET method). string.Compare does work though:
<Test()> _
Public Sub StringCompareTest()
Using adapter As New DataAccessAdapter
Dim metaData As New LinqMetaData(adapter)
Dim q = From c In metaData.Customer Where String.Compare(c.CustomerId, "CCCCC") < 0 Select c
Dim count As Integer = 0
For Each v In q
count += 1
Next
Assert.AreEqual(12, count)
End Using
End Sub
results in:
value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[NW26.Adapter.EntityClasses.CustomerEntity]).Where(c => (Compare(c.CustomerId, "CCCCC") < 0)).Select(c => c)
which results in the proper sql:
Generated Sql query:
Query: SELECT [LPA_L1].[Address], [LPA_L1].[City], [LPA_L1].[CompanyName], [LPA_L1].[ContactName], [LPA_L1].[ContactTitle], [LPA_L1].[Country], [LPA_L1].[CustomerID] AS [CustomerId], [LPA_L1].[Fax], [LPA_L1].[Phone], [LPA_L1].[PostalCode], [LPA_L1].[Region] FROM [Northwind].[dbo].[Customers] [LPA_L1] WHERE ( ( CASE WHEN [LPA_L1].[CustomerID] < @p4 THEN -1 WHEN [LPA_L1].[CustomerID] = @p4 THEN 0 ELSE 1 END < @p2))
Parameter: @p4 : String. Length: 5. Precision: 0. Scale: 0. Direction: Input. Value: "CCCCC".
Parameter: @p2 : Int32. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 0.
Looking at the linq provider, it contains a buggy CompareString mapping. The string.Compare() mapping is different, while it should be the same. Fixing...