I’m not going define what
LINQ to SharePoint is as it is out of the scope of this post. I’m going to list
out the advantages and the disadvantages of LINQ to SharePoint over CAML
queries that I have encountered. Let us
review the advantages first.
Advantages:
1. As is mentioned often,
it provides strongly typed objects, when using we get intellisense while coding.
So, our code will be more bugs free unlike the CAML Queries where the result
will be known only in the run time.
2. One advantage not
mentioned generally is that we can
compare two columns (fields) of a SharePoint list in LINQ queries which is
not possible in CAML queries.
3. We can also use LINQ to
SharePoint to generate some complex CAML queries
Disadvantages:
1. During the run time the
LINQ query itself gets converted into a
CAML query, which is an extra step ahead that takes more time. This can be
avoided if we write a CAML query itself straight away.
2. Also, we generate a DataContext class using the SPMetal.exe. This class is the one
which we use in our project to generate LINQ queries. This class is not generated dynamically. So, if we do any changes in
any of the lists or libraries in our site it is not reflected in the
DataContext class. We have to generate a new class whenever we make any changes
in the site.
3. Unlike CAML queries, LINQ to SharePoint has no use if we are going to access SharePoint data in Silverlight using Client Object Model.
4. Fields like Created, CreatedBy, Modified and ModifiedBy of a SharePoint list are not created by SPMetal to be used in the LINQ queries.
5. LINQ to SharePoint cannot be implemented for an External list.