0

I am new with sharepoint development.

I read more articles to read data from sharepoint list. I find Caml and linq i want to know what is the diff between Caml and linq to learn

1

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.

CAML Query Builder Download link

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.
2

1. CAML to SharePoint

Advantages:

  1. Native query syntax used by the SharePoint platform to access data held within content databases.
  2. Fairly simple and easy to generate queries.

Disadvantages:

  1. Not parsed by the compiler at compile time so no validation - errors only detected at runtime.
  2. Hard and time consuming to debug/troubleshoot.
  3. Extensive use of indexed properties to access data - invalid index value or keys not detected at compile time.
  4. The data returned from the query is placed in a SPListItem collection, which does not provide strongly typed business entities.

P.S. Try this link for creating a CAML query. It shows how one can create CAML query using CamlJs-Console which is a Chrome extension.

2. LINQ to SharePoint

Advantages:

  1. Provides a strongly typed data access layer.
  2. Strongly typed entity objects contain the SharePoint data (SQL-like) LINQ syntax to perform queries.
  3. Full design-time validation and IntelliSense support in Visual Studio 2010.

Disadvantages:

  1. Code is converted to CAML under the hood resulting in a slight performance hit.
  • 1
    I would also add that CAML is also available on the browser side through JavaScript, where LINQ is not. So if using JavaScript with a framework or SPFx, you will need to use CAML. – mannaggia May 12 '17 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.