Linq – what it is

Linq (Language Integrated Query) is a great new way of fetching data from a database.  If you’ve ever written a data driven application then you know the pain of writing SQL to interact with your database.  It’s always seemed clunky to me, here you are creating objects with properties but the way those objects get saved to a database and read back out is in a language completely different from what you program in.

Linq is an attempt to change that.  Where a standard query looks like this:

Select col1, col2, col3 from myTable where col1='this'

a Linq query is written in your code and looks like this:

     var vProducts =
        from p in products
        where p.UnitsInStock > 0
        select p;

To view more Linq examples this is a great resource:
101 LINQ Samples:


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