SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

What's a good way to perform an Exists or Count on the client object model classes?

I have list with views. I want to check if a view already exists before creating it. Tried a couple of things, but the only thing which actually seems to work is loading the entire collection and using a foreach to check each views' title. I was hoping for a neater way using Linq for instance.


  • Performing a Where on the ViewCollection and loading that with LoadQuery. But when you perform Count() on that collection, you get an error.
  • performing a Load on the entire Views collection and querying that; again an error.
  • performing a count and loading the result, seems to be unsupported
share|improve this question
up vote 2 down vote accepted

You could try using the ViewCollection.GetByTitle or List.GetView method to fetch the already existing view. If the view is present, it will be returned and you wont need to create the new view.

share|improve this answer

Just to add an example of it:

private static bool ListViewExists()
    ClientContext clientContext = new ClientContext("http://yoursharepointsiteurl");
    List list = clientContext.Web.Lists.GetByTitle("Test");
    ViewCollection views = list.Views;

    // Check if the view already exists
    View view = views.GetByTitle("All Items");


        return true;
    catch (Exception)
        return false;
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.