LINQ vs CAML for SharePoint


Disadvantages of CAML:

·         CAML query is text based so, if we are joining two lists across a lookup field there may be various problems associated with that.

·         There is no mechanism to know until run time if the query is written correctly or not. If the query is not correct, then it will simply fail at run time. Means it won't support at design time

·         When writing the query, you have no idea what CAML elements are legal in the syntax without having a reference open.

·         The query is somewhat difficult to understand. We cannot determine easily what the query is doing and what lists are being joined.

·         The data returned from the query is placed in a SPListItem collection, which does not provide strongly typed business entities.

 

Advantages of LINQ over CAML:
 
·         First advantage is, it is an object-oriented query language.

·         It can provide strongly typed objects at design time; we can create queries in code and can check that they are correct because we can the compiles the code.

·         The results are returned from queries are strongly typed objects, so the items and fields can provide compile-time checking.  

Disadvantages of Using LINQ

·         LINQ translates the LINQ queries into Collaborative Application Markup Language (CAML) queries thus adding an extra step for retrieving the items
·         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.
·         Unlike CAML queries, LINQ to SharePoint has no use if we are going to access SharePoint data in Silverlight using Client Object Model.
·         Fields like Created, CreatedBy, Modified and ModifiedBy of a SharePoint list are not created by SPMetal to be used in the LINQ queries.
·         LINQ to SharePoint cannot be implemented for an External list

 

 

Comments

Popular posts from this blog

Power BI Refresh Issue: unable to convert the value '' from the source data type 'VT_BSTR' to the expected data type 'VT_I8.

Run Powershell script on Remote Computer/Server

SPDActivities - DP.SharePoint.Workflow - Workflow failed to run