Tip #77: Don't use .Where extension method when querying ListItem objects

Rate this item
(0 votes)

Never use the IQueryable<T>.Where extension method when querying ListItem objects.

The reason is that the client object model first evaluates the result of the CAML query, retrieves the results, and then filters the resulting collection using LINQ. If you filter a very large list using LINQ instead of CAML, the client object model attempts to retrieve all items in the list before filtering with LINQ and either issues queries that require too much system resources, or the query fails. The reason is not clear unless you know how the client object model works internally.

You must use CAML when querying list items.

Source

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.