LINQ to SQL – Basic Join

July 16, 2008

Although LINQ ti SQL very much simplifys data based* operations, there is a slight learning curve with the upside-down syntax. Below is a simple query making a join on two tables:

from Obj in DB.PrimaryTable
join ForeignTableRef in DB.ForeignTable on Obj.PrimaryTableColumn equals ForeignTableRef.ForeignTableColumn
select Obj;

*Note I use the term ‘data based operations’, not ‘database operations’ – With LINQ we could be talking about business objects, XML data, typed lists, SQL data…etc!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: