Channel 9 Interview: LINQ Language Deep Dive with Visual Studio 2008
Ever wonder what really happens when you write a simple LINQ query?
Dim query = From row In db.Customers _
Where row.Country = "Canada" _
Select row
A lot of new language features went into the compilers in Visual Studio 2008 to make even this simple LINQ query work.
In this interview I sit down with Jonathan Aneja, a Program Manager on the Visual Basic Compiler team, who dives deep into these features like Type Inference, Anonymous Types, Lambda Expressions, Expressions Trees, and more. He explains what's actually happening behind the scenes and all the work the compiler is doing for you when you write a LINQ query.
My head almost explodes at the end but I learned a lot of important concepts so check it out:
LINQ Language Deep Dive with Visual Studio 2008
Enjoy!
Comments
Anonymous
July 22, 2009
Is he the same Jonathan with lots of blue shirts? :)Anonymous
July 22, 2009
LOL. It used to be grey shirts. http://blogs.msdn.com/vbteam/archive/2008/07/23/channel-9-interview-look-who-s-working-on-visual-basic-beth-massi.aspx I think Jonathan has finally expanded his wardrobe to two colors ;-)Anonymous
July 28, 2009
very thanks, in this vedio i have learn lot of the thing about linq queryAnonymous
September 01, 2009
I'd also like to acquire and share this well done video with my coleagues. We often share our ideas, thoughts, and info during brown bag lunche sessions. Thanks, James jas-list@ipns.comAnonymous
September 27, 2009
Thx a lot, it's really valuableAnonymous
October 26, 2009
Very informing, like it. Did get a little distracted by Jonathan saying 'Right' every 5 seconds, right? ;-)Anonymous
November 18, 2009
I have seen lots of videos for VB.net by Beth, but now I can put a face to the voice...very nice!Anonymous
February 18, 2010
The comment has been removedAnonymous
February 19, 2010
Hey Antony, The key thing to realize is that Nothing in VB doesn't mean null, it means "default value for type" (i.e. it's the equivalent of C#'s default(T) operator). When nothing is assigned to a reference type, it's default value is null. When it's assigned to an integer, the default value is zero. When assigned to a nullable integer, the value is null (and .HasValue would return false). The type of Nothing is inferred from its context, and in your example above the ternary operator is passed 3 arguments: a > 0 (type is boolean), Nothing (no type), and 2 (Integer). I'm simplifying what actually happens here, but basically the compiler runs it's "dominant type algorithm" and treats the Nothing literal as if its type were Integer, in which case you get 0 which is its default value. Now try this code instead: Dim x As Integer? Dim z As Integer? = 2 Dim a = 1 x = If(a > 0, Nothing, z) Here the ternary operator gets "Nothing" (no type) and "z" (type is Nullable Integer) - and so now the dominant type is Nullable(Of Integer) and Nothing is assigned to that. Now you'll see that x.HasValue is False. Lucian Wischik (Spec Lead for VB) has a good blog entry that touches on this a bit: http://blogs.msdn.com/lucian/archive/2008/11/05/my-dog-has-no-type.aspx Hope that helps, JonathanAnonymous
March 09, 2010
Jonathan, Thanks for the reply. It explained my quandary perfectly.Anonymous
August 13, 2010
No sirve para nada est blog es una estupides no ayuda