LINQ to SQL cheat sheet

August 12th 2009 • .NET (, ) • 29,898 views • 20 responses

A few short words to say I’ve put together a cheat sheet for LINQ to SQL with one page for C# and another for VB.NET.

Thumbnail of the LINQ to SQL Cheat Sheet PDF

It shows the syntax for a number of common query operations, manipulations and attributes and can be a very useful quick reference :)

Download LINQ to SQL cheat sheet (PDF) (76 KB)

[)amien

Related content

20 responses  

  1. Harry M on August 13th, 2009

    Hi Damien – FYI your anti hotlinking thing makes downloading the link from your post via my blog reader a bit tricky!

  2. Jeff Handley on August 13th, 2009

    This is excellent, thanks!

  3. Joel on August 13th, 2009

    Thanks for the sheet, I can see this being very helpful. It’s also quite nice that you split the C# & VB into separate pages.

  4. Damien Guard on August 13th, 2009

    @Harry I just enabled it for Google Reader, which one are you using?

    @Everyone Else: Thanks for the compliment guys. I’ve never been so retweeted.

    [)amien

  5. KristoferA on August 13th, 2009

    Very neat. I think you should put a link to the cheat sheet as a pegged topic in the msdn linq forums…

  6. Peter Bromberg on August 13th, 2009

    Nice job, Damien! Your efforts are appreciated!

  7. marcobdv on August 14th, 2009

    First of all a nice job, if you’re intrested we designed a poster for linq see http://www.infosupport.com/LINQ (site is in dutch) but google translate shoot help you there

  8. Pingback Dew Drop – August 14, 2009 | Alvin Ashcraft's Morning Dew on August 14th, 2009

    [...] LINQ to SQL cheat sheet (Damien Guard) [...]

  9. Jim Wooley on August 14th, 2009

    On your VB sheet, you should consider using the VB’s additional support of query operators Distinct, Skip, Take, Aggregate, Sum, Count, Etc. For example the Paging and Ordering example could be re-written in VB as:

    Dim page3 = From c In db.Customers _
    Order By c.ContactName, c.City Descending _
    Distinct _
    Skip 10 _
    Take 5

    Also, notice the Select is optional in VB if you project the entire object. When using a simple projection, you don’t need the object initializer syntax either. If you just wanted to project the ContactName and City in the above example, you could do the following:

    Dim page3 = From c In db.Customers _
    Order By c.ContactName, c.City Descending _
    Select Name = c.ContactName, c.City _
    Distinct _
    Skip 10 _
    Take 5

    VB takes away a number of the method syntax hurdles that C# requires.

  10. Damien Guard on August 14th, 2009

    Thanks Jim, I’ll update the sheet over the weekend with your changes.

    I have written a fair amount of code in VB.Net but I have to admit it was all prior to .NET 3.5.

    [)amien

  11. William Wegerson on August 14th, 2009

    Excellent and thanks! But one word though:

    landscape

    The boxes are cramped horizontally, maybe Landscape would allow for formatted code(?). Yes I know, everyone is a critic.

  12. Pingback LINQ to SQL Cheat Sheet « Technology and Information Blog on August 15th, 2009

    [...] http://damieng.com/blog/2009/08/12/linq-to-sql-cheat-sheet Posted by rthayne Filed in Uncategorized Leave a Comment » [...]

  13. Pingback Reading: Cloud, LinqMock and More « Tales from a Trading Desk on August 20th, 2009

    [...] to SQL cheat [...]

  14. Pingback LINQ to SQL resources » DamienG on August 20th, 2009

    [...] LINQ to SQL Cheat Sheet PDF download of the most popular query and update syntax for C# and VB.NET. [...]

  15. Milan Negovan on August 23rd, 2009

    Damien,

    Thank you for the cheat sheet! I made a similar one for LINQ Standard Query Operators

    Hope this helps anyone,
    Milan

  16. KALYAN on August 27th, 2009

    Thanks for the cheat sheet. It is just the one I was looking for.

  17. sshow on September 3rd, 2009

    You just managed to teach me LINQ to SQL in one A4 page.
    Thanks alot!

  18. Pingback Resumen de Instrucciones LINQ to SQL « on September 8th, 2009

    [...] Este resumen que pueden descargar en PDF lo encontre en el blog de damieng. [...]

  19. SoCalSam on November 18th, 2009

    Thanks Damien. I’m just starting a project that I wanted to use LINQ with, and this will help me a lot!

  20. ARLibertarian on March 6th, 2010

    Thanks a LOT. I’m doing a project and having to learn this stuff on the fly. This helps!

Leave your response

  1. (kept private)