Jasper and LINQ in CTP Samples

I'm looking at the VIsual Basic query samples and curious about the compile time checking in the LINQ samples. This may just be the mystery of Dynamic Languages...

In this code:

Code Snippet

Dim customers As Object = From c In CType(context.Customers, IQuery) _
Where c.Country = "USA" _
Order By c.CompanyName _
Select c

context.Customers is not strongly typed and we are doing late-binding. The code won't know what Customers are until the app is actually run. So we don't get Customers via intellisense (ooh that's not fun - I'm too spoiled) but why is it that the compiler is not complaining about context.Customers or c.Country or c.CompanyName? I thought strict might be relative to "option strict" but even if I set that to true, the compiler is happy.

Thanks

[966 byte] By [JulieLerman] at [2008-2-16]
# 1

There are a couple of things going on here.First of all, as of VS Studio 2008, Linq queries are only allowed to bind to objects of the type IEnumerable(of T) – so that is why we added the IQuery type which is IEnumerable(of object) since the root query objects (i.e. context.Customers) is typed as object.That allows the Linq operators to bind statically, but the calls to the objects are late bound. For that, I believe one needs option strict to be off.If option strict is on, then the compiler should error for c.Country, but not for context.Customers since it is strongly typed.If it is not raising the correct errors, then it is a bug with the VB compiler.Let me know if that is the case and I will get it filed.

Thanks –

Andy Conrad

AndrewConrad-MSFT at 2007-9-28 > top of Msdn Tech,Incubation Technologies,Project Codename: Jasper...