I'm trying to retrieve both a file's Id in its list, plus its ETag, using the following snippet;

using (var clientContext = new ClientContext(webUrl))
    var results = clientContext.Web.Lists

    clientContext.Load(results, files => files
            .Include(file => file.ETag)
            .Include(file => file.ListItemAllFields.Id));

    foreach (var file in results)
        Console.WriteLine(file.ETag + " " + file.ListItemAllFields.Id);

However, I'm getting the following exception;

The query expression 'files => files.Include(new [] {file => file.ETag}).Include(new [] {file => Convert(file.ListItemAllFields.Id)})' is not supported.

Am I forming my query correctly? It seems that if I query for the ETag by itself, then the query works. And also, if I query for the ListItemAllFields.Id by itself, then the query works.

It's when they are both included in the one query that the failure occurs.

1 Answer 1


Managed to work this one out with a bit of trial and error. The correct form of the query is;

    files => files.Include(file => file.ETag),
    files => files.Include(file => file.ListItemAllFields.Id));

Hopefully that's of some use to anyone else who encounters this issue.

  • Yes this is right. Also this same thing can help you get a Folder itemId. Jul 17, 2019 at 2:13
  • 2
    I knew it would be useful to someone! Didn't know it would be 7 years later, but worth it :) Jul 18, 2019 at 11:04
  • 1
    yeah when you contribute to stack exchange, you will be someone's hero 1,000's of miles away many years later. Jul 18, 2019 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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