Linq to Sharepoint "where" clause cannot be found

122 Views Asked by At

Hello stackoverflowers,

I'm trying to use LINQ to Sharepoint for the first time, but my where keyword isn't recognized : "Could not find an implementation of the query pattern for source type 'Microsoft.SharePoint.SPList'. 'Where' not found".

Here is the request :

using System.Linq;
[...]
  var query = from item in listToQuery
              where item.Site == _siteToQuery
              && item.ReportType == _recordTypeToQuery
              && item.Date == stringDate
              select item;
  Result = listToQuery.GetItems(query);

listToQuery and Result are two SPListItemCollection.

Why is where not recognized ?

1

There are 1 best solutions below

0
Nico On

It's normal. The SharePoint Object doesn't implement Linq query, so that's why you have this exception.

To Query a SharePoint List you need to use a CAML Query (with an object of type SPQuery ) you can find a lot of documentation on internet about "how to query a sharepoint list programmatically"

But if you still want to user LINQ on Sharepoint, you can use SPMetal