Wednesday, 6 February 2008

Left/Right Joins LINQ way too complicated in VB9

I was recently trying to use LINQ to join two tables using a Left Join, nothing complicated, in fact here's the SQL I was trying to replicate

select L.* from tbllocation L left join tblItem I on L.locationid = I.locationid where I.Locationid is null

I couldn't figure out how to do this, turning to Google I found this article

The Visual Basic Team : Converting SQL to LINQ, Part 8: Left/Right Outer Join (Bill Horst)

which is part of this excellent series or articles

Converting SQL to LINQ by Bill Horst

Bill states that "VB9 doesn't yet have smooth support for Left or Right Joins" and comes up with a solution using the group join. In my opinion this is far too complicated to me to use reliably. I'm sure I'd get it eventually but for now I've reverted back to using a simple stored procedure to return the information I want.

LINQ is good and I enjoy having my intellisensed database; sometimes however, LINQ can get in the way and I just need to get the job done.

Link

2 Comments:

Anonymous Anonymous said...

I noticed your post on Linq. No right of left join, wow!. In my opinion, developers should know sql inside out. I see no advantage to linq if you know sql. It takes a very intuitive language (SQL) and makes it more difficult.

21 November 2008 18:05  
Anonymous Anonymous said...

I'm not sure if its because I'm too much of a newbie at the whole LINQ thang, but I'm not sure I'm getting it fully. I can see the benefits when writing simple queries. Intellisense, strict typing etc, but as soon as it comes time to write something a bit more substantial it feels more like a hindrance than a help. And given that I like a standard approach to everything I'm starting to wonder should I be using LINQ at all?...

24 November 2008 11:19  

Post a Comment

Links to this post:

Create a Link

<< Home