CRM 2011 – Getting Started with LINQ in CRM 2011

I have been using LINQ with CRM 2011 and I have to say it’s awesome.  It’s a great way to code without having to write connectors to SQL databases.  I used to spend hours and days writing database code when I was a Java programmer, not to mention I am always forgetting how to write complex SQL statements joining tables etc.

LINQ is one of the areas that is well covered in the SDK, it has lots of examples and creating the dataContext is a piece of cake.  I went about learning LINQ a bit backwards because I got started with LINQ in CRM 2011 by just using the samples and then I have just finished reading a chapter on it for the 70-515 .NET 4 exam.

If you want to get started writing LINQ queries for CRM 2011, I found these pages from the SDK the most useful

Firstly you have the parts of a LINQ query




How to retrieve data using LINQ

then you have this page about the LINQ functions



An example on how to build a complex LINQ query

I would also recommend this page Use The Organisation Service Context Class, You need to know this because this creates the DataContext which LINQ uses to connect to the CRM database (which saves you writing all that troublesome code yourself)

finally to finish off you have the real winner, lots of LINQ Samples.  If you are going to click on one link then this is the one to go for because from this you will quickly understand enough to start writing your own LINQ queries.

SDK code Samples : queries

I found learning LINQ one of the easier parts of CRM 2011 and also one of the most beneficial.

These pages from the CRM 2011 – building LINQ queries

In This Section

Use LINQ to Construct a Query
Provides information about how to create LINQ queries. 

Use Late-Bound Entity Class with a LINQ Query
Learn how to use late-bound entity classes with LINQ. 

Order Results Using Entity Attributes with LINQ
Learn how to use Lookup attributes with LINQ. 

Filter Multiple Entities with LINQ
Learn how to work with multiple entities. 

Page Large Result Sets with LINQ
Learn how to use the Skip and Take operators to page query results. 

LINQ Query Examples
View LINQ sample queries. 

Sample: Create a LINQ Query
Learn how to create simple LINQ queries. 

Sample: Complex LINQ Queries
Learn how to create more complex LINQ queries. 

Sample: RetrieveMultiple With Condition Operators Using LINQ
Learn how to use retrieve multiple condition operators with LINQ. 

Sample: More LINQ Query Examples
Learn how to use Skip and TakeorderBy and complex where conditions. 

Sample: Use LINQ with Late Binding
Learn how to build LINQ queries that use late bound entities. 



3 thoughts on “CRM 2011 – Getting Started with LINQ in CRM 2011

  1. Sabine September 14, 2011 / 10:12 am

    All links which are on the resultondemand website are not working.
    Can you provide us with links we can use?
    thank you!🙂


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s