SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When using 'Contains' in Linq query:

var camlQuery = new CamlQuery();
var listItems = list.GetItems(camlQuery);

var itemQuery = listItems.Where(i => i.FieldValuesAsText["Title"].Contains("van")).Include(
    item => item["ID"],
    item => item["Title"]);

var itemsFound = clientContext.LoadQuery(itemQuery);

I get an error like: "The 'Contains' member cannot be used in the expression."

But when using a CamlQuery like:

var camlQuery = new CamlQuery();
camlQuery.ViewXml = @"
            <FieldRef Name='ID'/>
            <FieldRef Name='Title'/>
                    <FieldRef Name='Title' />
                    <Value Type='Text'>van</Value>


It works fine.

What is the explanation for this?

share|improve this question
I am unable to comment on the question so just posting my question under the answers. Did you find a solution to this issue? How were you able to achieve what is intended through the where clause? You inputs will be of great help! Thanks – jkr Oct 2 '15 at 9:30

Unfortunately this is a limitation of LINQ. I've had exactly the same error when using LINQ to SQL.

The problem is that LINQ only knows how to map certain operations. We can see string.Contains() and the <Contains>element are analogous to each other, but LINQ just sees an object's method and says "Does this match any of my recognised operations? Nope. Fail."

share|improve this answer

I am not sure, but FieldValuesAsText will return FieldStringValues.

So you need to convert it to string first and then need to check with contain option.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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